Skip to content

Commit 7af554a

Browse files
test: add test for issue #388 (#496)
1 parent 95c7570 commit 7af554a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/nullable.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,3 +444,23 @@ test('large array of nullable booleans with default mechanism', (t) => {
444444
t.same(result, JSON.stringify(data))
445445
t.same(JSON.parse(result), data)
446446
})
447+
448+
test('nullable type in the schema', (t) => {
449+
t.plan(2)
450+
451+
const schema = {
452+
type: ['object', 'null'],
453+
properties: {
454+
foo: {
455+
type: 'string'
456+
}
457+
}
458+
}
459+
460+
const stringify = build(schema)
461+
462+
const data = { foo: 'bar' }
463+
464+
t.same(stringify(data), JSON.stringify(data))
465+
t.same(stringify(null), JSON.stringify(null))
466+
})

0 commit comments

Comments
 (0)