Skip to content

Commit d662aee

Browse files
authored
improve coverage of ref-resolver to 100 % (#610)
1 parent 43f5ee9 commit d662aee

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/ref.test.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,3 +2078,42 @@ test('should throw an Error if two non-identical schemas with same id are provid
20782078

20792079
t.throws(() => build(schema), new Error('There is already another schema with id inner_schema'))
20802080
})
2081+
2082+
test('ref internal - throw if schema has definition twice with different shape', (t) => {
2083+
t.plan(1)
2084+
2085+
const schema = {
2086+
$id: 'test',
2087+
title: 'object with $ref',
2088+
definitions: {
2089+
def: {
2090+
$id: '#uri',
2091+
type: 'object',
2092+
properties: {
2093+
str: {
2094+
type: 'string'
2095+
}
2096+
},
2097+
required: ['str']
2098+
},
2099+
def2: {
2100+
$id: '#uri',
2101+
type: 'object',
2102+
properties: {
2103+
num: {
2104+
type: 'number'
2105+
}
2106+
},
2107+
required: ['num']
2108+
}
2109+
},
2110+
type: 'object',
2111+
properties: {
2112+
obj: {
2113+
$ref: '#uri'
2114+
}
2115+
}
2116+
}
2117+
2118+
t.throws(() => build(schema), Error('There is already another schema with id test##uri'))
2119+
})

0 commit comments

Comments
 (0)