Skip to content

Commit

Permalink
test: add test for issue #246 (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-tymoshenko committed Aug 2, 2022
1 parent b3f3baf commit d14112b
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/nullable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,3 +498,46 @@ test('throw an error if the value doesn\'t match the type', (t) => {
const invalidData = { data: [false, 'testing'] }
t.throws(() => stringify(invalidData))
})

test('nullable value in oneOf', (t) => {
t.plan(1)

const schema = {
type: 'object',
properties: {
data: {
oneOf: [
{
type: 'array',
items: {
type: 'object',
properties: {
id: { type: 'integer', minimum: 1 }
},
additionalProperties: false,
required: ['id']
}
},
{
type: 'array',
items: {
type: 'object',
properties: {
job: { type: 'string', nullable: true }
},
additionalProperties: false,
required: ['job']
}
}
]
}
},
required: ['data'],
additionalProperties: false
}

const stringify = build(schema)

const data = { data: [{ job: null }] }
t.equal(stringify(data), JSON.stringify(data))
})

0 comments on commit d14112b

Please sign in to comment.