Commit 5a278075ec43325cf000c2fcb66c71b38a75df86
Pass all the tests!!!!
Piet Geursen committed on 3/15/2018, 4:57:57 AMParent: 19874c0c0d66afbcbbf49555bb33b9b4de8909e4
Files changed
test/errors/sync/index.test.js | changed |
test/errors/sync/index.test.js | ||
---|---|---|
@@ -1,5 +1,7 @@ | ||
1 | 1 | const test = require('tape') |
2 | +const pull = require('pull-stream') | |
3 | +const pullAsync = require('pull-async') | |
2 | 4 | |
3 | 5 | const isPositionChoiceError = require('../../../errors/sync/isPositionChoiceError') |
4 | 6 | const isPositionLateError = require('../../../errors/sync/isPositionLateError') |
5 | 7 | const isPositionTypeError = require('../../../errors/sync/isPositionTypeError') |
@@ -7,47 +9,63 @@ | ||
7 | 9 | const PositionTypeError = require('../../../errors/sync/positionTypeError') |
8 | 10 | const PositionLateError = require('../../../errors/sync/positionLateError') |
9 | 11 | const PositionChoiceError = require('../../../errors/sync/positionChoiceError') |
10 | 12 | |
11 | -const ChooseOne = require('../../../position/sync/chooseOne') | |
13 | +const ChooseOne = require('../../../position/async/chooseOne')() | |
12 | 14 | |
13 | 15 | test('positionTypeError', function (t) { |
14 | - const validPosition = ChooseOne({ | |
15 | - poll: '%t+PhrNxxXkw/jMo6mnwUWfFjJapoPWxzsQoe0Np+nYw=.sha256', | |
16 | - choice: 0 | |
17 | - }) | |
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') | |
18 | 26 | |
19 | - var invalidError = PositionTypeError({}) | |
20 | - t.false(isPositionTypeError(invalidError), 'catches invalid error') | |
27 | + var validError = PositionTypeError({position: validPosition}) | |
28 | + t.true(isPositionTypeError(validError), 'validates valid error') | |
29 | + t.end() | |
30 | + }) | |
21 | 31 | |
22 | - var validError = PositionTypeError({position: validPosition}) | |
23 | - t.true(isPositionTypeError(validError), 'validates valid error') | |
24 | - t.end() | |
32 | + ) | |
25 | 33 | }) |
26 | 34 | |
27 | 35 | test('positionLateError', function (t) { |
28 | - const validPosition = ChooseOne({ | |
29 | - poll: '%t+PhrNxxXkw/jMo6mnwUWfFjJapoPWxzsQoe0Np+nYw=.sha256', | |
30 | - choice: 0 | |
31 | - }) | |
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') | |
32 | 46 | |
33 | - var invalidError = PositionLateError({}) | |
34 | - t.false(isPositionTypeError(invalidError), 'catches invalid error') | |
35 | - | |
36 | - var validError = PositionLateError({position: validPosition}) | |
37 | - t.true(isPositionLateError(validError), 'validates valid error') | |
38 | - t.end() | |
47 | + var validError = PositionLateError({position: validPosition}) | |
48 | + t.true(isPositionLateError(validError), 'validates valid error') | |
49 | + t.end() | |
50 | + }) | |
51 | + ) | |
39 | 52 | }) |
40 | 53 | |
41 | 54 | test('positionChoiceError', function (t) { |
42 | - const validPosition = ChooseOne({ | |
43 | - poll: '%t+PhrNxxXkw/jMo6mnwUWfFjJapoPWxzsQoe0Np+nYw=.sha256', | |
44 | - choice: 0 | |
45 | - }) | |
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') | |
46 | 65 | |
47 | - var invalidError = PositionChoiceError({}) | |
48 | - t.false(isPositionChoiceError(invalidError), 'catches invalid error') | |
49 | - | |
50 | - var validError = PositionChoiceError({position: validPosition}) | |
51 | - t.true(isPositionChoiceError(validError), 'validates valid error') | |
52 | - t.end() | |
66 | + var validError = PositionChoiceError({position: validPosition}) | |
67 | + t.true(isPositionChoiceError(validError), 'validates valid error') | |
68 | + t.end() | |
69 | + }) | |
70 | + ) | |
53 | 71 | }) |
Built with git-ssb-web