git ssb

0+

Piet / ssb-loomio



Tree: 37adf78cdbbd4382daca8b71e27337cdacfe5570

Files: 37adf78cdbbd4382daca8b71e27337cdacfe5570 / test / position / sync / chooseOne.test.js

1054 bytesRaw
1const test = require('tape')
2const ChooseOne = require('../../../position/sync/chooseOne')
3const isPosition = require('../../../isPosition')
4
5test('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
28 var fullPositionMsg = {
29 key: '%somekey',
30 value: {
31 content: validPosition
32 }
33 }
34 t.true(isPosition(fullPositionMsg), 'simple (full msg)')
35 // NOTE - we might want an isChooseOnePosition in future
36 // t.true(isChooseOnePosition(fullPositionMsg), 'simple (full msg)')
37
38 t.end()
39})
40

Built with git-ssb-web