From 40c206a68dc1761f5b832602a9dec0aadb1f6ac5 Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 22 Feb 2019 13:58:51 +0800 Subject: Use fakeAsync instead of async. --- .../app/todo-list-page/todo-list-page.component.spec.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.spec.ts') diff --git a/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.spec.ts b/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.spec.ts index 7fc4164d..7623d7aa 100644 --- a/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.spec.ts +++ b/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.spec.ts @@ -1,5 +1,5 @@ import { Component, NO_ERRORS_SCHEMA } from '@angular/core'; -import { async, ComponentFixture, TestBed, tick } from '@angular/core/testing'; +import { async, ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; import { defer, Observable } from 'rxjs'; @@ -45,21 +45,22 @@ describe('TodoListPageComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(TodoListPageComponent); component = fixture.componentInstance; - fixture.detectChanges(); }); it('should create', () => { + fixture.detectChanges(); expect(component).toBeTruthy(); }); it('should show progress bar during loading', () => { + fixture.detectChanges(); expect(fixture.debugElement.query(By.css('mat-progress-bar'))).toBeTruthy(); }); - it('should hide progress bar after loading', async(() => { - fixture.whenStable().then(() => { - fixture.detectChanges(); - expect(fixture.debugElement.query(By.css('mat-progress-bar'))).toBeFalsy(); - }); + it('should hide progress bar after loading', fakeAsync(() => { + fixture.detectChanges(); + tick(); + fixture.detectChanges(); + expect(fixture.debugElement.query(By.css('mat-progress-bar'))).toBeFalsy(); })); }); -- cgit v1.2.3 From 00814dccd8f26a6dd9cc9163fad05afafb1ae4e6 Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 22 Feb 2019 14:26:12 +0800 Subject: Upgrade packages and add tslint flag for stub component. --- .../ClientApp/src/app/todo-list-page/todo-list-page.component.spec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.spec.ts') diff --git a/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.spec.ts b/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.spec.ts index 7623d7aa..e01e91fb 100644 --- a/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.spec.ts +++ b/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.spec.ts @@ -8,7 +8,8 @@ import { TodoListService, WorkItem } from './todo-list.service'; import { By } from '@angular/platform-browser'; @Component({ - selector: 'mat-progress-bar', +/* tslint:disable-next-line:component-selector*/ +selector: 'mat-progress-bar', template: '' }) class MatProgressBarStubComponent { -- cgit v1.2.3