Skip to content

Commit 9d24a2a

Browse files
authored
add unit test for allOf, where types, format and nullable missmatch (#577)
* add unit test for allOf, where types missmatch * add test for format mismatch * add test for allOf nullable mismatch
1 parent 996b659 commit 9d24a2a

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

test/allof.test.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,3 +482,51 @@ test('allof with local anchor reference', (t) => {
482482

483483
t.equal(stringify(data), JSON.stringify(data))
484484
})
485+
486+
test('allOf: throw Error if types mismatch ', (t) => {
487+
t.plan(1)
488+
489+
const schema = {
490+
allOf: [
491+
{ type: 'string' },
492+
{ type: 'number' }
493+
]
494+
}
495+
t.throws(() => build(schema), new Error('allOf schemas have different type values'))
496+
})
497+
498+
test('allOf: throw Error if format mismatch ', (t) => {
499+
t.plan(1)
500+
501+
const schema = {
502+
allOf: [
503+
{ format: 'date' },
504+
{ format: 'time' }
505+
]
506+
}
507+
t.throws(() => build(schema), new Error('allOf schemas have different format values'))
508+
})
509+
510+
test('allOf: throw Error if nullable mismatch /1', (t) => {
511+
t.plan(1)
512+
513+
const schema = {
514+
allOf: [
515+
{ nullable: true },
516+
{ nullable: false }
517+
]
518+
}
519+
t.throws(() => build(schema), new Error('allOf schemas have different nullable values'))
520+
})
521+
522+
test('allOf: throw Error if nullable mismatch /2', (t) => {
523+
t.plan(1)
524+
525+
const schema = {
526+
allOf: [
527+
{ nullable: false },
528+
{ nullable: true }
529+
]
530+
}
531+
t.throws(() => build(schema), new Error('allOf schemas have different nullable values'))
532+
})

0 commit comments

Comments
 (0)