Files: 6736253e48a68510bc7290bfd2043b69e2643d0a / test / poll / sync / chooseOne.test.js
715 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.ok(isPoll(validPoll), 'simple') |
8 | |
9 | var fullPollMsg = { |
10 | key: '%somekey', |
11 | value: { |
12 | content: validPoll |
13 | } |
14 | } |
15 | t.ok(isPoll(fullPollMsg), 'simple (full msg)') |
16 | // NOTE - we might want an isChooseOnePoll in future |
17 | // t.ok(isChooseOnePoll(fullPollMsg), 'simple (full msg)') |
18 | |
19 | var missingTitle = ChooseOne({choices: 'how'}) |
20 | t.notOk(isPoll(missingTitle), 'only one choice => invalid') |
21 | t.ok(isPoll.errors, 'missing title => has errors') |
22 | |
23 | t.end() |
24 | }) |
25 |
Built with git-ssb-web