Files: f81bab2f5e5f60995b99ed6d9b588e91f0c47d1f / test / position / sync / chooseOne.test.js
1110 bytesRaw
1 | const test = require('tape') |
2 | const ChooseOne = require('../../../position/sync/chooseOne') |
3 | const isPosition = require('../../../isPosition') |
4 | |
5 | test('Position - ChooseOne', function (t) { |
6 | var missingChoice = ChooseOne({ |
7 | poll: '%t+PhrNxxXkw/jMo6mnwUWfFjJapoPWxzsQoe0Np+nYw=.sha256' |
8 | }) |
9 | t.false(isPosition(missingChoice), 'missing a choice') |
10 | |
11 | var missingPoll = ChooseOne({ |
12 | choice: 0 |
13 | }) |
14 | t.false(isPosition(missingPoll), 'missing a poll') |
15 | |
16 | var brokenPoll = ChooseOne({ |
17 | poll: 'dog?', |
18 | choice: 0 |
19 | }) |
20 | t.false(isPosition(missingPoll), 'does not reference a poll') |
21 | |
22 | var validPosition = ChooseOne({ |
23 | poll: '%t+PhrNxxXkw/jMo6mnwUWfFjJapoPWxzsQoe0Np+nYw=.sha256', |
24 | choice: 0 |
25 | }) |
26 | t.true(isPosition(validPosition), 'simple') |
27 | if (isPosition.errors) console.log(isPosition.errors) |
28 | |
29 | var fullPositionMsg = { |
30 | key: '%somekey', |
31 | value: { |
32 | content: validPosition |
33 | } |
34 | } |
35 | t.true(isPosition(fullPositionMsg), 'simple (full msg)') |
36 | // NOTE - we might want an isChooseOnePosition in future |
37 | // t.true(isChooseOnePosition(fullPositionMsg), 'simple (full msg)') |
38 | |
39 | t.end() |
40 | }) |
41 |
Built with git-ssb-web