git ssb

0+

Piet / ssb-loomio



Tree: a9066ada5725359824ce7bca9e5007251109f74c

Files: a9066ada5725359824ce7bca9e5007251109f74c / test / position / sync / chooseOne.test.js

1110 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 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