From fec4576d1b31553834983d7904e977a66581f731 Mon Sep 17 00:00:00 2001 From: Stephen Demjanenko Date: Tue, 3 Nov 2015 18:24:09 -0800 Subject: [PATCH 1/2] FormsySpec: test that `onChange` is called only once --- tests/Formsy-spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Formsy-spec.js b/tests/Formsy-spec.js index 1a52e5b..aae9c1a 100755 --- a/tests/Formsy-spec.js +++ b/tests/Formsy-spec.js @@ -350,7 +350,7 @@ export default { }, - 'should trigger onChange when form element is changed': function (test) { + 'should trigger onChange once when form element is changed': function (test) { const hasChanged = sinon.spy(); const form = TestUtils.renderIntoDocument( @@ -359,12 +359,12 @@ export default { ); TestUtils.Simulate.change(TestUtils.findRenderedDOMComponentWithTag(form, 'INPUT'), {target: {value: 'bar'}}); - test.equal(hasChanged.called, true); + test.equal(hasChanged.calledOnce, true); test.done(); }, - 'should trigger onChange when new input is added to form': function (test) { + 'should trigger onChange once when new input is added to form': function (test) { const hasChanged = sinon.spy(); const TestForm = React.createClass({ @@ -394,7 +394,7 @@ export default { const form = TestUtils.renderIntoDocument(); form.addInput(); immediate(() => { - test.equal(hasChanged.called, true); + test.equal(hasChanged.calledOnce, true); test.done(); }); From 1df3e3520f00b9b0d25d4892f9e77db8ba418d7e Mon Sep 17 00:00:00 2001 From: Stephen Demjanenko Date: Tue, 3 Nov 2015 18:32:48 -0800 Subject: [PATCH 2/2] Formsy.Form: omit Formsy-only props from the `
` component --- src/main.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index 7edb786..c2eaa43 100644 --- a/src/main.js +++ b/src/main.js @@ -424,9 +424,23 @@ Formsy.Form = React.createClass({ this.validateForm(); }, render: function () { + var { + mapping, + validationErrors, + onSubmit, + onValid, + onInvalid, + onInvalidSubmit, + onChange, + reset, + preventExternalInvalidation, + onSuccess, + onError, + ...nonFormsyProps + } = this.props; return ( - + {this.props.children}
);