Skip to content

Instantly share code, notes, and snippets.

@visualskyrim
Last active August 6, 2017 14:40
Show Gist options
  • Save visualskyrim/a158c05a04f32f563cdf5936d9510853 to your computer and use it in GitHub Desktop.
Save visualskyrim/a158c05a04f32f563cdf5936d9510853 to your computer and use it in GitHub Desktop.
Use Enzyme to test React/Redux container - dispatch
it("should render a text box with no string inside if search string is not provided by store", () => {
const testState = {
showBox: {
search: ""
}
};
const store = createMockStore(testState)
const component = shallowWithStore(<ConnectedShowBox />, store);
component.dive().find("form > div > input").simulate("change", { target: { value: "Site" } });
expect(component.dive().find("d").prop("value")).to.equal("Site")
component.dive().find("form").simulate("submit");
expect(store.isActionDispatched({
type: "showBox/SUBMIT",
searchString: "Site"
})).to.be.true;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment