Skip to content
Snippets Groups Projects
Commit 76b887fc authored by Atte Keinänen's avatar Atte Keinänen
Browse files

Fix issue with button-wrapping React components

parent ac1e19a4
No related branches found
No related tags found
No related merge requests found
......@@ -344,13 +344,14 @@ export const clickRouterLink = click
export const clickButton = (enzymeWrapper) => {
const closestButton = enzymeWrapper.closest("button");
// const childButton = enzymeWrapper.children("button");
if (closestButton.length === 1) {
closestButton.simulate("submit"); // for forms with onSubmit
closestButton.simulate("click"); // for lone buttons / forms without onSubmit
} else {
throw new Error('Couldn\'t find a button element to click in clickButton');
// Assume that the current component wraps a button element
enzymeWrapper.simulate("submit");
enzymeWrapper.simulate("click");
}
}
......
import {
login,
createTestStore,
createTestStore, clickButton,
} from "__support__/integrated_tests";
import {
......@@ -346,8 +346,7 @@ describe("FieldApp", () => {
lastMapping.find(Input).simulate('change', {target: {value: "Extraordinarily awesome"}});
const saveButton = valueRemappingsSection.find(ButtonWithStatus)
// TRY WITH clickButton !!!
saveButton.simulate("click");
clickButton(saveButton)
store.waitForActions([UPDATE_FIELD_VALUES]);
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment