-
-
Save lydemann/1b5aa49208d14b6e21ff8209a5001861 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 { BrowserModule } from '@angular/platform-browser'; | |
import { NO_ERRORS_SCHEMA } from '@angular/core'; | |
import { TodoListComponent } from './todo-list.component'; | |
import { TodoListService } from '../core/todo-list.service'; | |
import { TODOItem } from '../shared/models/todo-item'; | |
describe('TodoListComponent', () => { | |
let component: TodoListComponent; | |
let fixture: ComponentFixture<TodoListComponent>; | |
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: [ | |
TodoListComponent, | |
], | |
imports: [ | |
BrowserModule, | |
], | |
providers: [ | |
{ | |
provide: TodoListService, | |
useValue: {todoList: todoList} | |
} | |
], | |
schemas: [NO_ERRORS_SCHEMA] | |
}) | |
.compileComponents(); | |
})); | |
beforeEach(() => { | |
fixture = TestBed.createComponent(TodoListComponent); | |
component = fixture.componentInstance; | |
fixture.detectChanges(); | |
}); | |
it('should create', () => { | |
expect(component).toBeTruthy(); | |
}); | |
it('should have two completed TODO item', () => { | |
expect(component.todoList.length).toBe(2); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment