Skip to content

Commit c890062

Browse files
Add test for custom submit buttons
1 parent 6e28306 commit c890062

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/index_test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,23 @@ describe("Form", () => {
5858
});
5959
});
6060

61+
describe("Custom submit buttons", () => {
62+
it("should submit the form when clicked", () => {
63+
const onSubmit = sandbox.spy();
64+
const comp = renderIntoDocument(
65+
<Form onSubmit={ onSubmit } schema={ {} }>
66+
<button type="submit">Submit</button>
67+
<button type="submit">Another submit</button>
68+
</Form>
69+
);
70+
const node = findDOMNode(comp);
71+
const buttons = node.querySelectorAll("button[type=submit]");
72+
buttons[0].click();
73+
buttons[1].click();
74+
sinon.assert.calledTwice(onSubmit);
75+
});
76+
});
77+
6178
describe("Custom SchemaField", () => {
6279
const CustomSchemaField = function(props) {
6380
return (<div id="custom"><SchemaField {...props} /></div>);

0 commit comments

Comments
 (0)