Files: ff7663e73e7aedeb75242d658e91bb048df0253f / test / poll / sync / chooseOne.test.js
723 bytesRaw
1 | const test = require('tape') |
2 | const ChooseOne = require('../../../poll/sync/chooseOne') |
3 | const isPoll = require('../../../isPoll') |
4 | |
5 | test('ChooseOne', function (t) { |
6 | var validPoll = ChooseOne({choices: [1, 2, 'three'], title: 'how many food'}) |
7 | t.true(isPoll(validPoll), 'simple') |
8 | |
9 | var fullPollMsg = { |
10 | key: '%somekey', |
11 | value: { |
12 | content: validPoll |
13 | } |
14 | } |
15 | t.true(isPoll(fullPollMsg), 'simple (full msg)') |
16 | // NOTE - we might want an isChooseOnePoll in future |
17 | // t.true(isChooseOnePoll(fullPollMsg), 'simple (full msg)') |
18 | |
19 | var missingTitle = ChooseOne({choices: 'how'}) |
20 | t.false(isPoll(missingTitle), 'only one choice => invalid') |
21 | t.true(isPoll.errors, 'missing title => has errors') |
22 | |
23 | t.end() |
24 | }) |
25 |
Built with git-ssb-web