Skip to content

Commit

Permalink
Added test for rendering elements with PureRenderMixin and Formsy.Mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
Semigradsky committed Nov 5, 2015
1 parent 8636cda commit 59bde83
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"lolex": "^1.3.2",
"nodeunit": "^0.9.1",
"react": "^0.14.0-rc1",
"react-addons-pure-render-mixin": "^0.14.2",
"react-addons-test-utils": "^0.14.0-rc1",
"react-dom": "^0.14.0-rc1",
"sinon": "^1.17.1",
Expand Down
26 changes: 26 additions & 0 deletions tests/Element-spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import PureRenderMixin from 'react-addons-pure-render-mixin';
import sinon from 'sinon';

import Formsy from './..';
import TestInput, { InputFactory } from './utils/TestInput';
Expand Down Expand Up @@ -537,6 +539,30 @@ export default {

test.done();

},

'input should rendered once with PureRenderMixin': function (test) {

var renderSpy = sinon.spy();

const Input = InputFactory({
mixins: [Formsy.Mixin, PureRenderMixin],
render() {
renderSpy();
return <input type={this.props.type} value={this.getValue()} onChange={this.updateValue}/>;
}
});

const form = TestUtils.renderIntoDocument(
<Formsy.Form>
<Input name="foo" value="foo"/>
</Formsy.Form>
);

test.equal(renderSpy.calledOnce, true);

test.done();

}

};

0 comments on commit 59bde83

Please sign in to comment.