File tree 2 files changed +21
-5
lines changed
2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -32,9 +32,13 @@ export function next(state) {
32
32
}
33
33
34
34
export 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
+ }
40
44
}
Original file line number Diff line number Diff line change @@ -144,6 +144,18 @@ describe('application logic', () => {
144
144
) ;
145
145
} ) ;
146
146
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
+
147
159
} ) ;
148
160
149
161
} ) ;
You can’t perform that action at this time.
0 commit comments