Created
May 29, 2019 22:13
-
-
Save bradfordlemley/10001b8d8ed0a990cc1ccf594c098aac to your computer and use it in GitHub Desktop.
Testing state composition
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
// 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