Created
May 20, 2020 16:01
-
-
Save Rajdeepc/10e6f55cf2ce9479bec4d4eba9f7d55d to your computer and use it in GitHub Desktop.
Testing Async Redux Action
This file contains hidden or 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
| // | |
| const searchAction = (value) => dispatch => { | |
| dispatch({ | |
| type: SEARCH_TEXT, | |
| text: value | |
| }) | |
| } | |
| //Test | |
| describe("Testing searchAction()", () => { | |
| beforeEach(() => { | |
| // Runs before each test in the suite | |
| store.clearActions(); | |
| }); | |
| it("should get SEARCH_TEXT", () => { | |
| const value = "datastructure"; | |
| const expectedActions = [ | |
| { | |
| text: value, | |
| type: "SEARCH_TEXT", | |
| }, | |
| ]; | |
| store.dispatch(searchAction(value)); | |
| expect(store.getActions()).toEqual(expectedActions); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment