要求:我需要为
HTML元素的数据绑定属性编写单元测试.
这是代码:
<kendo-grid [kendoGridBinding]="gridData" [resizable]="true" style="height: 300px"> <kendo-grid-column field="UnitPrice" title="Unit Price" [width]="180" filter="numeric" format="{0:c}"> </kendo-grid-column> </kendo-grid>
我需要为可调整大小的属性值编写单元测试.
到目前为止我尝试了什么:
it('kendo-grid element should contain resizable attribute with "true" value',() => { const element = fixture.debugElement.nativeElement.querySelector('kendo-grid'); expect(element.resizable).toBeTruthy(); });
在运行Karma测试运行器时失败了.
任何帮助都会非常值得一提.
解决方法
这些属性在浏览器中转换为ng-reflect- {attributeName},因此jasmine需要查找该属性.下面的测试应该有效.
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'); });
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。