angular - Angular 单元测试没有任何返回语句的方法
问题描述
我的方法:
flyout() {
document.getElementById("transition1").style.cssText="transform:translateX(-120%)";
document.getElementById("transition2").style.cssText="transform:translateY(-120%)";
}
规格:
it('Tesing Void function', function() {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const component = fixture.debugElement.componentInstance;
component.flyOut();
// How should I write expect statement
});
谁能帮我写期望语句....
谢谢。!!!
解决方案
您可以在期望中查询您的元素并检查样式是否已应用。
fixture.detectChanges();
expect(fixture.debugElement.query(By.css('#transition1')).style.transform).toEqual('translateX(-120%)');
推荐阅读
- python - 读取以特定字符串 opencv - python 开头的图像
- eclipse - 当我想访问我使用 Eclipse 在 azure 中发布的应用程序时收到错误 HTTP 404
- python-3.x - Scrapy CrawlSpider:拒绝子域不起作用,为什么?
- c# - 查询“QueryName”的加载操作失败。远程服务器返回错误:未找到
- ruby - 如何在单个语句/检查中替换嵌套哈希的多个 nil 检查?
- resolve - 解析失败:multidex 打开文件 解析失败:运行时打开文件 解析失败:common 打开文件
- nuget - 如何弃用 nuget 包
- sitefinity - 我可以将 Sitefinity 数据库模式设置为 dbo 以外的模式吗?
- google-cloud-platform - Google Cloud HTTP 负载均衡器运行状况检查在没有外部 IP 的情况下失败
- mysql - 查询 HAVING MAX() 未按预期工作