Skip to content

improve statements coverage of ref-resolver to 100% #610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'))
})