git ssb

0+

Piet / ssb-loomio



Tree: a12ac40b656901d5dcfd3cf302343421e77045b0

Files: a12ac40b656901d5dcfd3cf302343421e77045b0 / test / errors / sync / index.test.js

1843 bytesRaw
1const test = require('tape')
2
3const isPositionChoiceError = require('../../../errors/sync/isPositionChoiceError')()
4const isPositionLateError = require('../../../errors/sync/isPositionLateError')()
5const isPositionTypeError = require('../../../errors/sync/isPositionTypeError')()
6
7const PositionTypeError = require('../../../errors/sync/positionTypeError')
8const PositionLateError = require('../../../errors/sync/positionLateError')
9const PositionChoiceError = require('../../../errors/sync/positionChoiceError')
10
11const ChooseOne = require('../../../position/sync/chooseOne')
12
13test('positionTypeError', function (t) {
14 var validPosition = ChooseOne({
15 poll: '%t+PhrNxxXkw/jMo6mnwUWfFjJapoPWxzsQoe0Np+nYw=.sha256',
16 choice: 0
17 })
18 var invalidError = PositionTypeError({})
19 t.false(isPositionTypeError(invalidError), 'catches invalid error')
20
21 var validError = PositionTypeError({position: validPosition})
22 t.true(isPositionTypeError(validError), 'validates valid error')
23 t.end()
24})
25
26test('positionLateError', function (t) {
27 var validPosition = ChooseOne({
28 poll: '%t+PhrNxxXkw/jMo6mnwUWfFjJapoPWxzsQoe0Np+nYw=.sha256',
29 choice: 0
30 })
31 var invalidError = PositionLateError({})
32 t.false(isPositionTypeError(invalidError), 'catches invalid error')
33
34 var validError = PositionLateError({position: validPosition})
35 t.true(isPositionLateError(validError), 'validates valid error')
36 t.end()
37})
38
39test('positionChoiceError', function (t) {
40 var validPosition = ChooseOne({
41 poll: '%t+PhrNxxXkw/jMo6mnwUWfFjJapoPWxzsQoe0Np+nYw=.sha256',
42 choice: 0
43 })
44 var invalidError = PositionChoiceError({})
45 t.false(isPositionChoiceError(invalidError), 'catches invalid error')
46
47 var validError = PositionChoiceError({position: validPosition})
48 t.true(isPositionChoiceError(validError), 'validates valid error')
49 t.end()
50})
51

Built with git-ssb-web