diff options
author | crupest <crupest@outlook.com> | 2019-02-22 13:58:51 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-02-22 13:58:51 +0800 |
commit | 40c206a68dc1761f5b832602a9dec0aadb1f6ac5 (patch) | |
tree | 5665bdb6146d4153bc7e98fdc7cbe5d89205fc7b /Timeline/ClientApp/src/app/todo-list-page | |
parent | 504d770e51a07ca7765de725979412b6dacdcf15 (diff) | |
download | timeline-40c206a68dc1761f5b832602a9dec0aadb1f6ac5.tar.gz timeline-40c206a68dc1761f5b832602a9dec0aadb1f6ac5.tar.bz2 timeline-40c206a68dc1761f5b832602a9dec0aadb1f6ac5.zip |
Use fakeAsync instead of async.
Diffstat (limited to 'Timeline/ClientApp/src/app/todo-list-page')
-rw-r--r-- | Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.spec.ts | 15 | ||||
-rw-r--r-- | Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.ts | 3 |
2 files changed, 9 insertions, 9 deletions
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(); })); }); diff --git a/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.ts b/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.ts index 8af1f5ef..06f49923 100644 --- a/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.ts +++ b/Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.ts @@ -11,10 +11,9 @@ export class TodoListPageComponent implements OnInit { items: WorkItem[]; constructor(private todoService: TodoListService) { - todoService.getWorkItemList().subscribe(result => this.items = result); } ngOnInit() { + this.todoService.getWorkItemList().subscribe(result => this.items = result); } - } |