Skip to content

Instantly share code, notes, and snippets.

@bradfordlemley
Created May 29, 2019 22:13
Show Gist options
  • Save bradfordlemley/10001b8d8ed0a990cc1ccf594c098aac to your computer and use it in GitHub Desktop.
Save bradfordlemley/10001b8d8ed0a990cc1ccf594c098aac to your computer and use it in GitHub Desktop.
Testing state composition
// reset state module for each test
let state;
beforeEach(() => {
jest.resetModules();
state = require('./state');
})
test('visibleTodos$ contains todos filtered thru visibilityFilter', () => {
const { todoLib, visibleTodos$ } = state;
todoLib.addTodo("First");
todoLib.addTodo("Second");
visLib.setVisibility("active");
expect(visibleTodos$.value).toHaveLength(2);
visLib.setVisibility("completed");
expect(visibleTodos$.value).toHaveLength(0);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment