Skip to content

Commit 207bf9b

Browse files
authored
Add more tests (#144)
1 parent 29edda4 commit 207bf9b

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

test/typesArray.test.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,31 @@ test('possibly nullable primitive alternative', (t) => {
2828
}
2929
})
3030

31+
test('possibly nullable primitive alternative with null value', (t) => {
32+
t.plan(1)
33+
34+
const schema = {
35+
title: 'simple object with multi-type nullable primitive',
36+
type: 'object',
37+
properties: {
38+
data: {
39+
type: ['integer']
40+
}
41+
}
42+
}
43+
44+
const stringify = build(schema)
45+
46+
try {
47+
const value = stringify({
48+
data: null
49+
})
50+
t.is(value, '{"data":null}')
51+
} catch (e) {
52+
t.fail()
53+
}
54+
})
55+
3156
test('nullable primitive', (t) => {
3257
t.plan(1)
3358

@@ -53,6 +78,31 @@ test('nullable primitive', (t) => {
5378
}
5479
})
5580

81+
test('nullable primitive with null value', (t) => {
82+
t.plan(1)
83+
84+
const schema = {
85+
title: 'simple object with nullable primitive',
86+
type: 'object',
87+
properties: {
88+
data: {
89+
type: ['integer', 'null']
90+
}
91+
}
92+
}
93+
94+
const stringify = build(schema)
95+
96+
try {
97+
const value = stringify({
98+
data: null
99+
})
100+
t.is(value, '{"data":null}')
101+
} catch (e) {
102+
t.fail()
103+
}
104+
})
105+
56106
test('possibly null object with multi-type property', (t) => {
57107
t.plan(3)
58108

0 commit comments

Comments
 (0)