From c4a44f9f219fb7d740342f2ba71008e693fcdf02 Mon Sep 17 00:00:00 2001 From: Ruben Costa Date: Tue, 28 May 2019 03:25:13 +0200 Subject: [PATCH] test(form): Element's sCU is called with correct value (#97) --- tests/Element-spec.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/Element-spec.js b/tests/Element-spec.js index 49b9f018..ad7a0592 100644 --- a/tests/Element-spec.js +++ b/tests/Element-spec.js @@ -607,6 +607,38 @@ export default { }, + 'input should call shouldComponentUpdate with correct value': function (test) { + + var renderSpy = sinon.spy(); + + const Input = InputFactory({ + shouldComponentUpdate: function(prevProps) { + return prevProps.value !== this.props.value + }, + render: function() { + renderSpy(); + return ; + } + }); + + const form = TestUtils.renderIntoDocument( + + + + ); + + const input = TestUtils.findRenderedDOMComponentWithTag(form, 'INPUT'); + + test.equal(renderSpy.calledOnce, true); + + TestUtils.Simulate.change(input, {target: {value: 'fooz'}}); + test.equal(input.value, 'fooz'); + test.equal(renderSpy.calledTwice, true); + + test.done(); + + }, + 'binds all necessary methods': function (test) { const onInputRef = input => { [