Created
July 9, 2018 06:32
-
-
Save lydemann/c8bad236ca1edf32d7a98c8a60a470fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | |
import { By, BrowserModule } from '@angular/platform-browser'; | |
import { TodoListCompletedComponent } from './todo-list-completed.component'; | |
import { AppComponent } from '../app.component'; | |
import { NavbarComponent } from '../navbar/navbar.component'; | |
import { TodoListComponent } from '../todo-list/todo-list.component'; | |
import { TodoItemComponent } from '../todo-item/todo-item.component'; | |
import { FooterComponent } from '../footer/footer.component'; | |
import { AddTodoComponent } from '../add-todo/add-todo.component'; | |
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; | |
import { FormsModule } from '@angular/forms'; | |
import { appRouterModule, completedTodoPath } from '../app.routes'; | |
import { APP_BASE_HREF } from '@angular/common'; | |
import { TodoListService } from '../core/todo-list.service'; | |
import { TODOItem } from '../shared/models/todo-item'; | |
describe('TodoListCompletedComponent', () => { | |
let component: TodoListCompletedComponent; | |
let fixture: ComponentFixture<TodoListCompletedComponent>; | |
beforeEach(async(() => { | |
const todo1 = new TODOItem('Buy milk', 'Remember to buy milk'); | |
todo1.completed = true; | |
const todoList = [ | |
todo1, | |
new TODOItem('Buy flowers', 'Remember to buy flowers'), | |
]; | |
TestBed.configureTestingModule({ | |
declarations: [ | |
AppComponent, | |
NavbarComponent, | |
TodoListComponent, | |
TodoItemComponent, | |
FooterComponent, | |
AddTodoComponent, | |
TodoListCompletedComponent, | |
], | |
imports: [ | |
BrowserModule, | |
NgbModule.forRoot(), | |
FormsModule, | |
appRouterModule | |
], | |
providers: [ | |
{provide: APP_BASE_HREF, useValue : completedTodoPath }, | |
{ | |
provide: TodoListService, | |
useValue: { | |
todoList: todoList | |
} | |
} | |
] | |
}) | |
.compileComponents(); | |
})); | |
beforeEach(() => { | |
fixture = TestBed.createComponent(TodoListCompletedComponent); | |
component = fixture.componentInstance; | |
fixture.detectChanges(); | |
}); | |
it('should create', () => { | |
expect(component).toBeTruthy(); | |
}); | |
it('should have one completed TODO item', () => { | |
expect(component.todoList.length).toBe(1); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment