git ssb

0+

Piet / ssb-loomio



Commit ea5b79333882e7151bb0a468ae07577c8b4d05fa

Adds and passes tests.

Piet Geursen committed on 3/8/2018, 3:25:15 AM
Parent: fc8bb05bb0f604d21fc1a884234db8e0d49f1967

Files changed

errors/schema/positionChoiceError.jschanged
errors/schema/positionLateError.jschanged
errors/schema/positionTypeError.jschanged
test/errors/sync/index.test.jsadded
errors/schema/positionChoiceError.jsView
@@ -1,6 +1,6 @@
11 const errorSchema = require('./error')
2-const cloneDeep = require('lodash.cedeep')
2+const cloneDeep = require('lodash.clonedeep')
33
44 const schema = cloneDeep(errorSchema)
55
66 // collapse the details down to be ONLY choice error
errors/schema/positionLateError.jsView
@@ -1,6 +1,6 @@
11 const errorSchema = require('./error')
2-const cloneDeep = require('lodash.cedeep')
2+const cloneDeep = require('lodash.clonedeep')
33
44 const schema = cloneDeep(errorSchema)
55
66 // collapse the details down to be ONLY late error
errors/schema/positionTypeError.jsView
@@ -1,6 +1,6 @@
11 const errorSchema = require('./error')
2-const cloneDeep = require('lodash.cedeep')
2+const cloneDeep = require('lodash.clonedeep')
33
44 const schema = cloneDeep(errorSchema)
55
66 // collapse the details down to be ONLY type error
test/errors/sync/index.test.jsView
@@ -1,0 +1,51 @@
1+const test = require('tape')
2+
3+const isError = require('../../../errors/sync/isError')
4+const isPositionChoiceError = require('../../../errors/sync/isPositionChoiceError')()
5+const isPositionLateError = require('../../../errors/sync/isPositionLateError')()
6+const isPositionTypeError = require('../../../errors/sync/isPositionTypeError')()
7+
8+const positionTypeError = require('../../../errors/sync/positionTypeError')
9+const positionLateError = require('../../../errors/sync/positionLateError')
10+const positionChoiceError = require('../../../errors/sync/positionChoiceError')
11+
12+const ChooseOne = require('../../../position/sync/chooseOne')
13+
14+test('positionTypeError', function (t) {
15+ var validPosition = ChooseOne({
16+ poll: '%t+PhrNxxXkw/jMo6mnwUWfFjJapoPWxzsQoe0Np+nYw=.sha256',
17+ choice: 0
18+ })
19+ var invalidError = positionTypeError({})
20+ t.false(isPositionTypeError(invalidError), 'catches invalid error')
21+
22+ var validError = positionTypeError({position: validPosition})
23+ t.true(isPositionTypeError(validError), 'validates valid error')
24+ t.end()
25+})
26+
27+test('positionLateError', function (t) {
28+ var validPosition = ChooseOne({
29+ poll: '%t+PhrNxxXkw/jMo6mnwUWfFjJapoPWxzsQoe0Np+nYw=.sha256',
30+ choice: 0
31+ })
32+ var invalidError = positionLateError({})
33+ t.false(isPositionTypeError(invalidError), 'catches invalid error')
34+
35+ var validError = positionLateError({position: validPosition})
36+ t.true(isPositionLateError(validError), 'validates valid error')
37+ t.end()
38+})
39+
40+test('positionChoiceError', function (t) {
41+ var validPosition = ChooseOne({
42+ poll: '%t+PhrNxxXkw/jMo6mnwUWfFjJapoPWxzsQoe0Np+nYw=.sha256',
43+ choice: 0
44+ })
45+ var invalidError = positionChoiceError({})
46+ t.false(isPositionChoiceError(invalidError), 'catches invalid error')
47+
48+ var validError = positionChoiceError({position: validPosition})
49+ t.true(isPositionChoiceError(validError), 'validates valid error')
50+ t.end()
51+})

Built with git-ssb-web