git ssb

0+

Piet / ssb-loomio



Tree: 94589ffe4b48f63a75b21a0142f48465fd3e0a18

Files: 94589ffe4b48f63a75b21a0142f48465fd3e0a18 / test / poll / sync / isPoll.test.js

1628 bytesRaw
1const test = require('tape')
2const ChooseOne = require('../../../poll/sync/chooseOne')
3const isPoll = require('../../../isPoll')
4
5// this is for testing the attributes that are required for all polls
6
7test('Poll - common requirements', function (t) {
8 var missingTitle = ChooseOne({
9 choices: [1, 2, 'three'],
10 closesAt: Date.now()
11 })
12 t.false(isPoll(missingTitle), 'needs title')
13
14 var missingClosesAt = ChooseOne({
15 choices: [1, 2, 'three'],
16 title: 'how many food'
17 })
18 t.false(isPoll(missingClosesAt), 'needs closes at')
19
20 var missingDetails = {
21 type: 'poll',
22 pollDetails: undefined,
23 title: 'how many food',
24 closesAt: Date.now()
25 }
26 t.false(isPoll(missingDetails), 'needs details')
27 t.true(isPoll.errors, 'failing validations have errors')
28
29 var fullyFeatured = {
30 type: 'poll',
31 pollDetails: {
32 type: 'chooseOnePoll', // TODO change to chooseOne?
33 title: 'how many dogs?',
34 choices: [1, 2, 3]
35 },
36 title: 'how many food',
37 body: 'this is really important, please let me know',
38 mentions: [
39 {name: 'mix', link: '@ye+QM09iPcDJD6YvQYjoQc7sLF/IFhmNbEqgdzQo3lQ=.ed25519'},
40 {name: 'sweet drawing', link: '&mwILr7kd1Tug/4vX5nW6YORhyununwkO4cF6jbiSyoA=.sha256'},
41 {link: '%s8uVi560mwpE8ncjT+eMz5XBQBREdk4exvM3D6dIg9g=.sha256'}
42 ],
43 recps: [
44 '@ye+QM09iPcDJD6YvQYjoQc7sLF/IFhmNbEqgdzQo3lQ=.ed25519',
45 {name: 'mix', link: '@ye+QM09iPcDJD6YvQYjoQc7sLF/IFhmNbEqgdzQo3lQ=.ed25519'}
46 ],
47 closesAt: Date.now()
48 }
49 t.true(isPoll(fullyFeatured), 'fully featured')
50 if (isPoll.errors) console.log(isPoll.errors)
51
52 t.end()
53})
54

Built with git-ssb-web