aboutsummaryrefslogtreecommitdiff
path: root/Timeline/ClientApp/src
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-02-24 00:14:59 +0800
committercrupest <crupest@outlook.com>2019-02-24 00:14:59 +0800
commitdd33a3df1027e3aa5f89935c54749c3ace68eea7 (patch)
tree498aff0de327220aa483fe01052535e826296578 /Timeline/ClientApp/src
parent83b91e17b2d8eb7d05c6a07a43fe94b3bec18a5e (diff)
downloadtimeline-dd33a3df1027e3aa5f89935c54749c3ace68eea7.tar.gz
timeline-dd33a3df1027e3aa5f89935c54749c3ace68eea7.tar.bz2
timeline-dd33a3df1027e3aa5f89935c54749c3ace68eea7.zip
Update unit tests.
Diffstat (limited to 'Timeline/ClientApp/src')
-rw-r--r--Timeline/ClientApp/src/app/todo-item/todo-item.component.spec.ts34
-rw-r--r--Timeline/ClientApp/src/app/todo-list-page/todo-list-page.component.spec.ts10
2 files changed, 31 insertions, 13 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);
+ });
});
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 9543f7ad..590c5ef0 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
@@ -68,14 +68,4 @@ 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);
- });
- }));
});