diff options
author | 杨宇千 <crupest@outlook.com> | 2019-02-23 16:25:34 +0000 |
---|---|---|
committer | 杨宇千 <crupest@outlook.com> | 2019-02-23 16:25:34 +0000 |
commit | bb537be81802998820b9ee07d7d887d4bd5c0665 (patch) | |
tree | 498aff0de327220aa483fe01052535e826296578 /Timeline/ClientApp/src/app/todo-item | |
parent | 83b91e17b2d8eb7d05c6a07a43fe94b3bec18a5e (diff) | |
parent | dd33a3df1027e3aa5f89935c54749c3ace68eea7 (diff) | |
download | timeline-bb537be81802998820b9ee07d7d887d4bd5c0665.tar.gz timeline-bb537be81802998820b9ee07d7d887d4bd5c0665.tar.bz2 timeline-bb537be81802998820b9ee07d7d887d4bd5c0665.zip |
Merged PR 7: Update unit tests.
Update unit tests.
Related work items: #6
Diffstat (limited to 'Timeline/ClientApp/src/app/todo-item')
-rw-r--r-- | Timeline/ClientApp/src/app/todo-item/todo-item.component.spec.ts | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/Timeline/ClientApp/src/app/todo-item/todo-item.component.spec.ts b/Timeline/ClientApp/src/app/todo-item/todo-item.component.spec.ts index 7ec7d768..245f9141 100644 --- a/Timeline/ClientApp/src/app/todo-item/todo-item.component.spec.ts +++ b/Timeline/ClientApp/src/app/todo-item/todo-item.component.spec.ts @@ -1,25 +1,53 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { TodoItemComponent } from './todo-item.component'; +import { WorkItem } from '../todo-list-page/todo-list.service'; +import { By } from '@angular/platform-browser'; +import { NO_ERRORS_SCHEMA } from '@angular/core'; describe('TodoItemComponent', () => { let component: TodoItemComponent; let fixture: ComponentFixture<TodoItemComponent>; + let mockWorkItem: WorkItem; + beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ TodoItemComponent ] - }) - .compileComponents(); + declarations: [TodoItemComponent], + schemas: [NO_ERRORS_SCHEMA] + }).compileComponents(); })); beforeEach(() => { + mockWorkItem = { + id: 0, + title: 'Title', + closed: true, + detailUrl: '/detail', + iconUrl: '/icon' + }; + fixture = TestBed.createComponent(TodoItemComponent); component = fixture.componentInstance; + component.item = mockWorkItem; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('should set icon', () => { + expect(fixture.debugElement.query(By.css('img.item-icon')).properties['src']).toBe(mockWorkItem.iconUrl); + }); + + it('should set title', () => { + expect((fixture.debugElement.query(By.css('span.item-title')).nativeElement as HTMLSpanElement).textContent).toBe( + mockWorkItem.id + '. ' + mockWorkItem.title + ); + }); + + it('should set detail link', () => { + expect(fixture.debugElement.query(By.css('a.item-detail-button')).properties['href']).toBe(mockWorkItem.detailUrl); + }); }); |