Skip to content

Instantly share code, notes, and snippets.

@Rajdeepc
Created May 20, 2020 16:01
Show Gist options
  • Save Rajdeepc/10e6f55cf2ce9479bec4d4eba9f7d55d to your computer and use it in GitHub Desktop.
Save Rajdeepc/10e6f55cf2ce9479bec4d4eba9f7d55d to your computer and use it in GitHub Desktop.
Testing Async Redux Action
//
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