git ssb

0+

Piet / ssb-loomio



Commit 8e0f851a65304725b4dee57658fafae8f4121658

Pass errors tests

Piet Geursen committed on 3/11/2018, 10:08:38 PM
Parent: be47c4200236fb818783a444f2a01b0707ec0a46

Files changed

test/errors/sync/index.test.jschanged
test/errors/sync/index.test.jsView
@@ -1,5 +1,7 @@
11 const test = require('tape')
2 +const pull = require('pull-stream')
3 +const pullAsync = require('pull-async')
24
35 const isPositionChoiceError = require('../../../errors/sync/isPositionChoiceError')()
46 const isPositionLateError = require('../../../errors/sync/isPositionLateError')()
57 const isPositionTypeError = require('../../../errors/sync/isPositionTypeError')()
@@ -7,44 +9,63 @@
79 const PositionTypeError = require('../../../errors/sync/positionTypeError')
810 const PositionLateError = require('../../../errors/sync/positionLateError')
911 const PositionChoiceError = require('../../../errors/sync/positionChoiceError')
1012
11-const ChooseOne = require('../../../position/sync/chooseOne')
13 +const ChooseOne = require('../../../position/async/chooseOne')
1214
1315 test('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')
16 + pull(
17 + pullAsync(cb => {
18 + ChooseOne({
19 + poll: '%t+PhrNxxXkw/jMo6mnwUWfFjJapoPWxzsQoe0Np+nYw=.sha256',
20 + choice: 0
21 + }, cb)
22 + }),
23 + pull.drain(validPosition => {
24 + var invalidError = PositionTypeError({})
25 + t.false(isPositionTypeError(invalidError), 'catches invalid error')
2026
21- var validError = PositionTypeError({position: validPosition})
22- t.true(isPositionTypeError(validError), 'validates valid error')
23- t.end()
27 + var validError = PositionTypeError({position: validPosition})
28 + t.true(isPositionTypeError(validError), 'validates valid error')
29 + t.end()
30 + })
31 +
32 + )
2433 })
2534
2635 test('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')
36 + pull(
37 + pullAsync(cb => {
38 + ChooseOne({
39 + poll: '%t+PhrNxxXkw/jMo6mnwUWfFjJapoPWxzsQoe0Np+nYw=.sha256',
40 + choice: 0
41 + }, cb)
42 + }),
43 + pull.drain(validPosition => {
44 + var invalidError = PositionLateError({})
45 + t.false(isPositionTypeError(invalidError), 'catches invalid error')
3346
34- var validError = PositionLateError({position: validPosition})
35- t.true(isPositionLateError(validError), 'validates valid error')
36- t.end()
47 + var validError = PositionLateError({position: validPosition})
48 + t.true(isPositionLateError(validError), 'validates valid error')
49 + t.end()
50 + })
51 + )
3752 })
3853
3954 test('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')
55 + pull(
56 + pullAsync(cb => {
57 + ChooseOne({
58 + poll: '%t+PhrNxxXkw/jMo6mnwUWfFjJapoPWxzsQoe0Np+nYw=.sha256',
59 + choice: 0
60 + }, cb)
61 + }),
62 + pull.drain(validPosition => {
63 + var invalidError = PositionChoiceError({})
64 + t.false(isPositionChoiceError(invalidError), 'catches invalid error')
4665
47- var validError = PositionChoiceError({position: validPosition})
48- t.true(isPositionChoiceError(validError), 'validates valid error')
49- t.end()
66 + var validError = PositionChoiceError({position: validPosition})
67 + t.true(isPositionChoiceError(validError), 'validates valid error')
68 + t.end()
69 + })
70 + )
5071 })

Built with git-ssb-web