From ad16dbe268984d639c4924fb8bb1e69e68c0fef7 Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 25 Feb 2019 00:40:27 +0800 Subject: Add entrance animation of todo item. --- .../todo-list-page.component.spec.ts | 43 +++++++++++++--------- 1 file changed, 26 insertions(+), 17 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 aed32c9a..a757b2a5 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,23 +1,23 @@ import { Component, NO_ERRORS_SCHEMA } from '@angular/core'; import { async, ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; -import { defer, Observable } from 'rxjs'; +import { Observable, from } from 'rxjs'; import { TodoListPageComponent } from './todo-list-page.component'; import { TodoListService, WorkItem } from './todo-list.service'; import { By } from '@angular/platform-browser'; +import { delay } from 'rxjs/operators'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; @Component({ /* tslint:disable-next-line:component-selector*/ selector: 'mat-progress-bar', template: '' }) -class MatProgressBarStubComponent { +class MatProgressBarStubComponent {} -} - -function asyncData(data: T): Observable { - return defer(() => Promise.resolve(data)); +function asyncArray(data: T[]): Observable { + return from(data).pipe(delay(0)); } describe('TodoListPageComponent', () => { @@ -29,22 +29,31 @@ describe('TodoListPageComponent', () => { beforeEach(async(() => { const todoListService: jasmine.SpyObj = jasmine.createSpyObj('TodoListService', ['getWorkItemList']); - mockWorkItems = [{ - id: 0, title: 'Test title 1', isCompleted: true, detailUrl: 'https://test.org/workitems/0', iconUrl: 'https://test.org/icon/0' - }, { - id: 1, title: 'Test title 2', isCompleted: false, detailUrl: 'https://test.org/workitems/1', iconUrl: 'https://test.org/icon/1' - }]; + mockWorkItems = [ + { + id: 0, + title: 'Test title 1', + isCompleted: true, + detailUrl: 'https://test.org/workitems/0', + iconUrl: 'https://test.org/icon/0' + }, + { + id: 1, + title: 'Test title 2', + isCompleted: false, + detailUrl: 'https://test.org/workitems/1', + iconUrl: 'https://test.org/icon/1' + } + ]; - todoListService.getWorkItemList.and.returnValue(asyncData(mockWorkItems)); + todoListService.getWorkItemList.and.returnValue(asyncArray(mockWorkItems)); TestBed.configureTestingModule({ declarations: [TodoListPageComponent, MatProgressBarStubComponent], - providers: [ - { provide: TodoListService, useValue: todoListService } - ], + imports: [NoopAnimationsModule], + providers: [{ provide: TodoListService, useValue: todoListService }], schemas: [NO_ERRORS_SCHEMA] - }) - .compileComponents(); + }).compileComponents(); })); beforeEach(() => { -- cgit v1.2.3