Skip to content

Commit

Permalink
test: add test for issue #388
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-tymoshenko committed Jul 30, 2022
1 parent 95c7570 commit 1c31195
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/nullable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,3 +444,23 @@ test('large array of nullable booleans with default mechanism', (t) => {
t.same(result, JSON.stringify(data))
t.same(JSON.parse(result), data)
})

test('nullable type in the schema', (t) => {
t.plan(2)

const schema = {
type: ['object', 'null'],
properties: {
foo: {
type: 'string'
}
}
}

const stringify = build(schema)

const data = { foo: 'bar' }

t.same(stringify(data), JSON.stringify(data))
t.same(stringify(null), JSON.stringify(null))
})

0 comments on commit 1c31195

Please sign in to comment.