作者:奶爸乳酪 | 来源:互联网 | 2022-12-07 00:33
要求:我需要为data-binding
属性编写单元测试HTML element
.
这是代码:
我需要为resizable
属性值编写单元测试.
到目前为止我尝试了什么:
it('kendo-grid element should contain resizable attribute with "true" value', () => {
const element = fixture.debugElement.nativeElement.querySelector('kendo-grid');
expect(element.resizable).toBeTruthy();
});
在运行Karma测试运行器时失败了.
任何帮助都会非常值得一提.
1> Okan Aslanka..:
这些属性在浏览器中转换为ng-reflect- {attributeName},因此茉莉花需要寻找该属性。下面的测试应该工作。
it('kendo-grid element should contain resizable attribute with "true" value', () => {
const element = fixture.debugElement.query(By.css('kendo-grid'));
expect(element.nativeElement.getAttribute('ng-reflect-resizable')).toBe('true');
});