Permalink
Browse files

invalid vote prevention

  • Loading branch information...
teropa committed Sep 6, 2015
1 parent 97416af commit a6bc6f4feb9efe21166f23d5776fc64129742133
Showing with 21 additions and 5 deletions.
  1. +9 −5 src/core.js
  2. +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')
})
);
});
});
});

0 comments on commit a6bc6f4

Please sign in to comment.