Skip to content

Instantly share code, notes, and snippets.

@lydemann
Created August 26, 2019 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lydemann/3a02696636eaa0befda5fb2fbcca05e6 to your computer and use it in GitHub Desktop.
Save lydemann/3a02696636eaa0befda5fb2fbcca05e6 to your computer and use it in GitHub Desktop.
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