Files: 6ff5525de64024e3f4384c5852534166d5c68063 / test / position / sync / chooseOneResults.test.js
1963 bytesRaw
1 | const test = require('tape') |
2 | const ChooseOne = require('../../../position/sync/chooseOne') |
3 | const Position = require('../../../position/sync/position') |
4 | const chooseOneResults = require('../../../position/sync/chooseOneResults') |
5 | |
6 | const pietId = '@Mq8D3YC6VdErKQzV3oi2oK5hHSoIwR0hUQr4M46wr/0=.ed25519' |
7 | const mixId = '@Mq8D3YC6VdErKQzV3oi2oK5hHSoIwR0hUQr4M46wr/1=.ed25519' |
8 | const mikeyId = '@Mq8D3YC6VdErKQzV3oi2oK5hHSoIwR0hUQr4M46wr/2=.ed25519' |
9 | const timmyId = '@Mq8D3YC6VdErKQzV3oi2oK5hHSoIwR0hUQr4M46wr/3=.ed25519' |
10 | const tommyId = '@Mq8D3YC6VdErKQzV3oi2oK5hHSoIwR0hUQr4M46wr/4=.ed25519' |
11 | const sallyId = '@Mq8D3YC6VdErKQzV3oi2oK5hHSoIwR0hUQr4M46wr/5=.ed25519' |
12 | |
13 | const poll = '%t+PhrNxxXkw/jMo6mnwUWfFjJapoPWxzsQoe0Np+nYw=.sha256' |
14 | |
15 | test('Position - ChooseOneResults', function (t) { |
16 | const positions = [ |
17 | { value: { content: Position(ChooseOne({choice: 0, poll})), author: pietId } }, |
18 | { value: { content: Position(ChooseOne({choice: 0, poll})), author: mixId } }, |
19 | { value: { content: Position(ChooseOne({choice: 0, poll})), author: mikeyId } }, |
20 | { value: { content: Position(ChooseOne({choice: 1, poll})), author: timmyId } }, |
21 | { value: { content: Position(ChooseOne({choice: 1, poll})), author: tommyId } }, |
22 | { value: { content: Position(ChooseOne({choice: 2, poll})), author: sallyId } } |
23 | ] |
24 | |
25 | const actual = chooseOneResults({positions}) |
26 | t.deepEqual(actual[0], [pietId, mixId, mikeyId], 'correct voters for choice 0') |
27 | t.deepEqual(actual[1], [timmyId, tommyId], 'correct voters for choice 1') |
28 | t.deepEqual(actual[2], [sallyId], 'correct voters for choice 2') |
29 | t.end() |
30 | }) |
31 | |
32 | test.skip('Position - a position stated for an invalid choice index is not counted', function(t) { |
33 | |
34 | t.end() |
35 | }) |
36 | |
37 | test.skip('Position - a position stated for an invalid choice index is included in the errors object', function(t) { |
38 | |
39 | t.end() |
40 | }) |
41 | |
42 | test.skip('Position - A position stated after the closing time of the poll is not counted', function(t) { |
43 | |
44 | t.end() |
45 | }) |
46 |
Built with git-ssb-web