【发布时间】:2019-11-13 05:36:21
【问题描述】:
我在我的组件上使用ngx-spinner 在某个远程调用过程的页面上显示加载指示符。在我的组件上,我有以下 ngx spinner 代码:
<ngx-spinner [fullScreen]="true" type="ball-clip-rotate" size="medium" bdColor="rgba(51,51,51,0.1)" color="grey">
</ngx-spinner>
在页面加载时的 init 组件中,我正在显示微调器,如下所示:"
constructor(
private spinner: NgxSpinnerService) {
}
ngOnInit() {
this.spinner.show();
在我对服务器进行远程调用之后,当这项工作完成后,我将隐藏微调器。
我的目标是创建相同的单元测试,即当页面加载时,我需要确保微调器显示在页面上。为此,我编写了以下测试用例:
it('should show loading indicator if the page is not loaded', () => {
// pageLoaded should be try because the form will be loaded only when that is true based on ng if
const element = getElementByTag('ngx-spinner');
//What to write here?
});
我在测试中获得了该元素,但我无法检测它是否可见。我试过 element.nativeElement.visible 但它返回为 null。
【问题讨论】:
标签: angular typescript