Skip to content

Commit

Permalink
fix setProps warning (fixes teropa#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanem committed Dec 6, 2015
1 parent c6df821 commit 2aa840e
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions test/components/Voting_spec.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ReactDOM from 'react-dom';
import React from 'react/addons';
import {List} from 'immutable';
import {Voting} from '../../src/components/Voting';
Expand Down Expand Up @@ -70,30 +71,40 @@ describe('Voting', () => {

it('renders as a pure component', () => {
const pair = ['Trainspotting', '28 Days Later'];
const component = renderIntoDocument(
<Voting pair={pair} />
const div = document.createElement('div');
const component = ReactDOM.render(
<Voting pair={pair} />,
div
);

let firstButton = scryRenderedDOMComponentsWithTag(component, 'button')[0];
expect(firstButton.textContent).to.equal('Trainspotting');

pair[0] = 'Sunshine';
component.setProps({pair: pair});
ReactDOM.render(
<Voting pair={pair} />,
div
);
firstButton = scryRenderedDOMComponentsWithTag(component, 'button')[0];
expect(firstButton.textContent).to.equal('Trainspotting');
});

it('does update DOM when prop changes', () => {
const pair = List.of('Trainspotting', '28 Days Later');
const component = renderIntoDocument(
<Voting pair={pair} />
const div = document.createElement('div');
const component = ReactDOM.render(
<Voting pair={pair} />,
div
);

let firstButton = scryRenderedDOMComponentsWithTag(component, 'button')[0];
expect(firstButton.textContent).to.equal('Trainspotting');

const newPair = pair.set(0, 'Sunshine');
component.setProps({pair: newPair});
ReactDOM.render(
<Voting pair={newPair} />,
div
);
firstButton = scryRenderedDOMComponentsWithTag(component, 'button')[0];
expect(firstButton.textContent).to.equal('Sunshine');
});
Expand Down

0 comments on commit 2aa840e

Please sign in to comment.