File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,9 +32,13 @@ export function next(state) {
3232}
3333
3434export function vote ( voteState , entry ) {
35- return voteState . updateIn (
36- [ 'tally' , entry ] ,
37- 0 ,
38- tally => tally + 1
39- ) ;
35+ if ( voteState . get ( 'pair' ) . includes ( entry ) ) {
36+ return voteState . updateIn (
37+ [ 'tally' , entry ] ,
38+ 0 ,
39+ tally => tally + 1
40+ ) ;
41+ } else {
42+ return voteState ;
43+ }
4044}
Original file line number Diff line number Diff line change @@ -144,6 +144,18 @@ describe('application logic', () => {
144144 ) ;
145145 } ) ;
146146
147+ it ( 'ignores the vote if for an invalid entry' , ( ) => {
148+ expect (
149+ vote ( Map ( {
150+ pair : List . of ( 'Trainspotting' , '28 Days Later' )
151+ } ) , 'Sunshine' )
152+ ) . to . equal (
153+ Map ( {
154+ pair : List . of ( 'Trainspotting' , '28 Days Later' )
155+ } )
156+ ) ;
157+ } ) ;
158+
147159 } ) ;
148160
149161} ) ;
You can’t perform that action at this time.
0 commit comments