Skip to content

Instantly share code, notes, and snippets.

@lydemann
Last active September 9, 2022 15:48
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/97969c9319a9f4f8296eb0d63da82fe1 to your computer and use it in GitHub Desktop.
Save lydemann/97969c9319a9f4f8296eb0d63da82fe1 to your computer and use it in GitHub Desktop.
todo-list.effects.spec.ts
describe('TodoListEffects', () => {
let actions: Observable<any>;
let effects: TodoListEffects;
beforeEach(() => {
TestBed.configureTestingModule({
providers: [
TodoListEffects,
provideMockActions(() => actions),
mockProvider(TodoListResourcesService),
],
});
effects = TestBed.inject(TodoListEffects);
});
it('should return a stream with todo list loaded action', () => {
const todoList: TODOItem[] = [{ title: '', id: '1', description: '' }];
const action = new LoadTodoList();
const outcome = new TodoItemsLoaded(todoList);
actions = hot('-a', { a: action });
const response = cold('-a|', { a: todoList });
todoListService.getTodos.and.returnValue(response);
const expected = cold('--b', { b: outcome });
expect(effects.loadTodoList$).toBeObservable(expected);
});
});
@alsoicode
Copy link

@lydemann where does mockProvider come from?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment