Skip to content

Commit

Permalink
improve coverage of ref-resolver to 100 % (#610)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak authored Feb 25, 2023
1 parent 43f5ee9 commit d662aee
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/ref.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2078,3 +2078,42 @@ test('should throw an Error if two non-identical schemas with same id are provid

t.throws(() => build(schema), new Error('There is already another schema with id inner_schema'))
})

test('ref internal - throw if schema has definition twice with different shape', (t) => {
t.plan(1)

const schema = {
$id: 'test',
title: 'object with $ref',
definitions: {
def: {
$id: '#uri',
type: 'object',
properties: {
str: {
type: 'string'
}
},
required: ['str']
},
def2: {
$id: '#uri',
type: 'object',
properties: {
num: {
type: 'number'
}
},
required: ['num']
}
},
type: 'object',
properties: {
obj: {
$ref: '#uri'
}
}
}

t.throws(() => build(schema), Error('There is already another schema with id test##uri'))
})

0 comments on commit d662aee

Please sign in to comment.