const test = require('tape') const ChooseOne = require('../../../poll/sync/chooseOne') const isPoll = require('../../../isPoll') // this is for testing the attributes that are required for all polls test('Poll - common requirements', function (t) { var missingTitle = ChooseOne({ choices: [1, 2, 'three'], closesAt: Date.now() }) t.false(isPoll(missingTitle), 'needs title') var missingClosesAt = ChooseOne({ choices: [1, 2, 'three'], title: 'how many food' }) t.false(isPoll(missingClosesAt), 'needs closes at') var missingDetails = { type: 'poll', pollDetails: undefined, title: 'how many food', closesAt: Date.now() } t.false(isPoll(missingDetails), 'needs details') t.true(isPoll.errors, 'failing validations have errors') var fullyFeatured = { type: 'poll', pollDetails: { type: 'chooseOnePoll', // TODO change to chooseOne? title: 'how many dogs?', choices: [1, 2, 3] }, title: 'how many food', body: 'this is really important, please let me know', mentions: [ {name: 'mix', link: '@ye+QM09iPcDJD6YvQYjoQc7sLF/IFhmNbEqgdzQo3lQ=.ed25519'}, {name: 'sweet drawing', link: '&mwILr7kd1Tug/4vX5nW6YORhyununwkO4cF6jbiSyoA=.sha256'}, {link: '%s8uVi560mwpE8ncjT+eMz5XBQBREdk4exvM3D6dIg9g=.sha256'} ], recps: [ '@ye+QM09iPcDJD6YvQYjoQc7sLF/IFhmNbEqgdzQo3lQ=.ed25519', {name: 'mix', link: '@ye+QM09iPcDJD6YvQYjoQc7sLF/IFhmNbEqgdzQo3lQ=.ed25519'} ], closesAt: Date.now() } t.true(isPoll(fullyFeatured), 'fully featured') if (isPoll.errors) console.log(isPoll.errors) t.end() })