Skip to content

Commit 59bde83

Browse files
author
Semigradsky
committed
Added test for rendering elements with PureRenderMixin and Formsy.Mixin
1 parent 8636cda commit 59bde83

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"lolex": "^1.3.2",
3535
"nodeunit": "^0.9.1",
3636
"react": "^0.14.0-rc1",
37+
"react-addons-pure-render-mixin": "^0.14.2",
3738
"react-addons-test-utils": "^0.14.0-rc1",
3839
"react-dom": "^0.14.0-rc1",
3940
"sinon": "^1.17.1",

tests/Element-spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react';
22
import TestUtils from 'react-addons-test-utils';
3+
import PureRenderMixin from 'react-addons-pure-render-mixin';
4+
import sinon from 'sinon';
35

46
import Formsy from './..';
57
import TestInput, { InputFactory } from './utils/TestInput';
@@ -537,6 +539,30 @@ export default {
537539

538540
test.done();
539541

542+
},
543+
544+
'input should rendered once with PureRenderMixin': function (test) {
545+
546+
var renderSpy = sinon.spy();
547+
548+
const Input = InputFactory({
549+
mixins: [Formsy.Mixin, PureRenderMixin],
550+
render() {
551+
renderSpy();
552+
return <input type={this.props.type} value={this.getValue()} onChange={this.updateValue}/>;
553+
}
554+
});
555+
556+
const form = TestUtils.renderIntoDocument(
557+
<Formsy.Form>
558+
<Input name="foo" value="foo"/>
559+
</Formsy.Form>
560+
);
561+
562+
test.equal(renderSpy.calledOnce, true);
563+
564+
test.done();
565+
540566
}
541567

542568
};

0 commit comments

Comments
 (0)