Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
invalid vote prevention
- Loading branch information
Showing
with
21 additions
and
5 deletions.
-
+9
−5
src/core.js
-
+12
−0
test/core_spec.js
|
@@ -32,9 +32,13 @@ export function next(state) { |
|
|
} |
|
|
|
|
|
export function vote(voteState, entry) { |
|
|
return voteState.updateIn( |
|
|
['tally', entry], |
|
|
0, |
|
|
tally => tally + 1 |
|
|
); |
|
|
if (voteState.get('pair').includes(entry)) { |
|
|
return voteState.updateIn( |
|
|
['tally', entry], |
|
|
0, |
|
|
tally => tally + 1 |
|
|
); |
|
|
} else { |
|
|
return voteState; |
|
|
} |
|
|
} |
|
@@ -144,6 +144,18 @@ describe('application logic', () => { |
|
|
); |
|
|
}); |
|
|
|
|
|
it('ignores the vote if for an invalid entry', () => { |
|
|
expect( |
|
|
vote(Map({ |
|
|
pair: List.of('Trainspotting', '28 Days Later') |
|
|
}), 'Sunshine') |
|
|
).to.equal( |
|
|
Map({ |
|
|
pair: List.of('Trainspotting', '28 Days Later') |
|
|
}) |
|
|
); |
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.