Created
August 26, 2019 07:00
-
-
Save lydemann/3a02696636eaa0befda5fb2fbcca05e6 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 { TestBed } from '@angular/core/testing'; | |
import { Store } from '@ngrx/store'; | |
import { MockStore, provideMockStore } from '@ngrx/store/testing'; | |
import { first } from 'rxjs/operators'; | |
import { TodoListService } from '@app/core/todo-list/todo-list.service'; | |
import { TODOItem } from '@app/shared/models/todo-item'; | |
import { TodoListState } from './redux-api/todo-list.model'; | |
describe('Service: TodoList', () => { | |
let todoListService: TodoListService; | |
let store: MockStore<TodoListState>; | |
const initialState = {}; | |
beforeEach(() => { | |
TestBed.configureTestingModule({ | |
providers: [ | |
todoListService, | |
{ | |
provide: | |
}, | |
provideMockStore({ initialState }), | |
], | |
}); | |
todoListService = TestBed.get(todoListService); | |
store = TestBed.get(Store); | |
}); | |
it('should return the todo list', (done) => { | |
const todoList = [{ | |
id: 'some-todo-item1' | |
} as TODOItem]; | |
store.setState({ todos: todoList, isLoading: false }) | |
todoListService.todoList$.pipe(first()).subscribe((todoList) => { | |
expect(todoList).toBe(todoList); | |
done(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment