Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.