From d662aeece0c47e1e6010e07df40080a61e0fec6b Mon Sep 17 00:00:00 2001 From: Uzlopak Date: Sat, 25 Feb 2023 22:24:13 +0100 Subject: [PATCH] improve coverage of ref-resolver to 100 % (#610) --- test/ref.test.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/ref.test.js b/test/ref.test.js index 0798731b..886f7996 100644 --- a/test/ref.test.js +++ b/test/ref.test.js @@ -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')) +})