From e236b5064cd62f40bc910fafe48ac4b9701a4bcd Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 22 Feb 2019 23:09:07 +0800 Subject: Develop link feature on todo page. --- .../todo-list-page.component.spec.ts | 26 +++++++++++++++++----- 1 file changed, 20 insertions(+), 6 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 e01e91fb..2da74002 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,8 +8,8 @@ import { TodoListService, WorkItem } from './todo-list.service'; import { By } from '@angular/platform-browser'; @Component({ -/* tslint:disable-next-line:component-selector*/ -selector: 'mat-progress-bar', + /* tslint:disable-next-line:component-selector*/ + selector: 'mat-progress-bar', template: '' }) class MatProgressBarStubComponent { @@ -24,14 +24,18 @@ describe('TodoListPageComponent', () => { let component: TodoListPageComponent; let fixture: ComponentFixture; + let mockWorkItems: WorkItem[]; + beforeEach(async(() => { const todoListService: jasmine.SpyObj = jasmine.createSpyObj('TodoListService', ['getWorkItemList']); - todoListService.getWorkItemList.and.returnValue(asyncData([{ - id: 0, title: 'Test title 1', closed: true + mockWorkItems = [{ + id: 0, title: 'Test title 1', closed: true, detailUrl: 'https://test.org/workitems/0' }, { - id: 1, title: 'Test title 2', closed: false - }])); + id: 1, title: 'Test title 2', closed: false, detailUrl: 'https://test.org/workitems/1' + }]; + + todoListService.getWorkItemList.and.returnValue(asyncData(mockWorkItems)); TestBed.configureTestingModule({ declarations: [TodoListPageComponent, MatProgressBarStubComponent], @@ -64,4 +68,14 @@ describe('TodoListPageComponent', () => { fixture.detectChanges(); expect(fixture.debugElement.query(By.css('mat-progress-bar'))).toBeFalsy(); })); + + it('should set href on item title', fakeAsync(() => { + fixture.detectChanges(); + tick(); + fixture.detectChanges(); + + fixture.debugElement.queryAll(By.css('a.item-title')).forEach((element, index) => { + expect(element.properties['href']).toBe(mockWorkItems[index].detailUrl); + }); + })); }); -- cgit v1.2.3