Skip to content

Commit

Permalink
restart functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
teropa committed Sep 10, 2015
1 parent 59a8b52 commit f314bce
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/action_creators.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ export function next() {
type: 'NEXT'
};
}

export function restart() {
return {
meta: {remote: true},
type: 'RESTART'
};
}
4 changes: 4 additions & 0 deletions src/components/Results.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export const Results = React.createClass({
)}
</div>
<div className="management">
<button ref="restart"
onClick={this.props.restart}>
Restart
</button>
<button ref="next"
className="next"
onClick={this.props.next}>
Expand Down
13 changes: 13 additions & 0 deletions test/components/Results_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ describe('Results', () => {
expect(nextInvoked).to.equal(true);
});

it('invokes action callback when restart button is clicked', () => {
let restartInvoked = false;
const pair = List.of('Trainspotting', '28 Days Later');
const component = renderIntoDocument(
<Results pair={pair}
tally={Map()}
restart={() => restartInvoked = true}/>
);
Simulate.click(React.findDOMNode(component.refs.restart));

This comment has been minimized.

Copy link
@kwhitejr

kwhitejr Jun 4, 2016

Line 50 should be:

Simulate.click(ReactDOM.findDOMNode(component.refs.restart));

React --> ReactDOM


expect(restartInvoked).to.equal(true);
});

it('renders the winner when there is one', () => {
const component = renderIntoDocument(
<Results winner="Trainspotting"
Expand Down

0 comments on commit f314bce

Please sign in to comment.