Skip to content

Commit f314bce

Browse files
committed
restart functionality
1 parent 59a8b52 commit f314bce

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/action_creators.js

+7
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,10 @@ export function next() {
2626
type: 'NEXT'
2727
};
2828
}
29+
30+
export function restart() {
31+
return {
32+
meta: {remote: true},
33+
type: 'RESTART'
34+
};
35+
}

src/components/Results.jsx

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ export const Results = React.createClass({
3939
)}
4040
</div>
4141
<div className="management">
42+
<button ref="restart"
43+
onClick={this.props.restart}>
44+
Restart
45+
</button>
4246
<button ref="next"
4347
className="next"
4448
onClick={this.props.next}>

test/components/Results_spec.js

+13
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ describe('Results', () => {
3939
expect(nextInvoked).to.equal(true);
4040
});
4141

42+
it('invokes action callback when restart button is clicked', () => {
43+
let restartInvoked = false;
44+
const pair = List.of('Trainspotting', '28 Days Later');
45+
const component = renderIntoDocument(
46+
<Results pair={pair}
47+
tally={Map()}
48+
restart={() => restartInvoked = true}/>
49+
);
50+
Simulate.click(React.findDOMNode(component.refs.restart));
51+
52+
expect(restartInvoked).to.equal(true);
53+
});
54+
4255
it('renders the winner when there is one', () => {
4356
const component = renderIntoDocument(
4457
<Results winner="Trainspotting"

0 commit comments

Comments
 (0)