@@ -144,15 +144,15 @@ const EXTRA_EXPECTED = { type: 'string', title: 'foo' };
144
144
145
145
describe ( 'findSchemaDefinition()' , ( ) => {
146
146
it ( 'throws error when ref is missing' , ( ) => {
147
- expect ( ( ) => findSchemaDefinition ( ) ) . toThrowError ( 'Could not find a definition for undefined' ) ;
147
+ expect ( ( ) => findSchemaDefinition ( ) ) . toThrow ( 'Could not find a definition for undefined' ) ;
148
148
} ) ;
149
149
it ( 'throws error when ref is malformed' , ( ) => {
150
- expect ( ( ) => findSchemaDefinition ( 'definitions/missing' ) ) . toThrowError (
150
+ expect ( ( ) => findSchemaDefinition ( 'definitions/missing' ) ) . toThrow (
151
151
'Could not find a definition for definitions/missing' ,
152
152
) ;
153
153
} ) ;
154
154
it ( 'throws error when ref does not exist' , ( ) => {
155
- expect ( ( ) => findSchemaDefinition ( '#/definitions/missing' , schema ) ) . toThrowError (
155
+ expect ( ( ) => findSchemaDefinition ( '#/definitions/missing' , schema ) ) . toThrow (
156
156
'Could not find a definition for #/definitions/missing' ,
157
157
) ;
158
158
} ) ;
@@ -166,22 +166,22 @@ describe('findSchemaDefinition()', () => {
166
166
expect ( findSchemaDefinition ( '#/definitions/extraNestedRef' , schema ) ) . toEqual ( EXTRA_EXPECTED ) ;
167
167
} ) ;
168
168
it ( 'throws error when ref is a circular reference' , ( ) => {
169
- expect ( ( ) => findSchemaDefinition ( '#/definitions/badCircularNestedRef' , schema ) ) . toThrowError (
169
+ expect ( ( ) => findSchemaDefinition ( '#/definitions/badCircularNestedRef' , schema ) ) . toThrow (
170
170
'Definition for #/definitions/badCircularNestedRef is a circular reference' ,
171
171
) ;
172
172
} ) ;
173
173
it ( 'throws error when ref is a deep circular reference' , ( ) => {
174
- expect ( ( ) => findSchemaDefinition ( '#/definitions/badCircularDeepNestedRef' , schema ) ) . toThrowError (
174
+ expect ( ( ) => findSchemaDefinition ( '#/definitions/badCircularDeepNestedRef' , schema ) ) . toThrow (
175
175
'Definition for #/definitions/badCircularDeepNestedRef contains a circular reference through #/definitions/badCircularDeeperNestedRef -> #/definitions/badCircularDeepestNestedRef -> #/definitions/badCircularDeepNestedRef' ,
176
176
) ;
177
177
} ) ;
178
178
it ( 'throws error when bundled ref are not part of JSON Schema Draft 2020-12' , ( ) => {
179
- expect ( ( ) => findSchemaDefinition ( '#/definitions/bundledRef' , schema ) ) . toThrowError (
179
+ expect ( ( ) => findSchemaDefinition ( '#/definitions/bundledRef' , schema ) ) . toThrow (
180
180
'Could not find a definition for /bundled.ref.json' ,
181
181
) ;
182
182
} ) ;
183
183
it ( 'throws error when bundled ref with explicit baseURI are not part of JSON Schema Draft 2020-12' , ( ) => {
184
- expect ( ( ) => findSchemaDefinition ( '#/properties/num' , schema , 'https://example.com/bundled.ref.json' ) ) . toThrowError (
184
+ expect ( ( ) => findSchemaDefinition ( '#/properties/num' , schema , 'https://example.com/bundled.ref.json' ) ) . toThrow (
185
185
'Could not find a definition for #/properties/num' ,
186
186
) ;
187
187
} ) ;
@@ -224,43 +224,43 @@ describe('findSchemaDefinition()', () => {
224
224
) ;
225
225
} ) ;
226
226
it ( 'throws error when relative ref is undefined in a bundled JSON Schema' , ( ) => {
227
- expect ( ( ) => findSchemaDefinition ( '#/$defs/undefinedRef' , bundledSchema ) ) . toThrowError (
227
+ expect ( ( ) => findSchemaDefinition ( '#/$defs/undefinedRef' , bundledSchema ) ) . toThrow (
228
228
'Could not find a definition for /undefined.ref.json' ,
229
229
) ;
230
230
} ) ;
231
231
it ( 'throws error when relative ref with anchor is undefined in a bundled JSON Schema' , ( ) => {
232
- expect ( ( ) => findSchemaDefinition ( '#/$defs/undefinedRefWithAnchor' , bundledSchema ) ) . toThrowError (
232
+ expect ( ( ) => findSchemaDefinition ( '#/$defs/undefinedRefWithAnchor' , bundledSchema ) ) . toThrow (
233
233
'Could not find a definition for #/$defs/undefined' ,
234
234
) ;
235
235
} ) ;
236
236
it ( 'throws error when local ref is undefined in a bundled JSON Schema with explicit base URI' , ( ) => {
237
237
expect ( ( ) =>
238
238
findSchemaDefinition ( '#/properties/undefined' , bundledSchema , 'https://example.com/bundled.ref.json' ) ,
239
- ) . toThrowError ( 'Could not find a definition for #/properties/undefined' ) ;
239
+ ) . toThrow ( 'Could not find a definition for #/properties/undefined' ) ;
240
240
} ) ;
241
241
it ( 'throws error when explicit base URI is undefined in a bundled JSON Schema' , ( ) => {
242
242
expect ( ( ) =>
243
243
findSchemaDefinition ( '#/properties/undefined' , bundledSchema , 'https://example.com/undefined.ref.json' ) ,
244
- ) . toThrowError ( 'Could not find a definition for #/properties/undefined' ) ;
244
+ ) . toThrow ( 'Could not find a definition for #/properties/undefined' ) ;
245
245
} ) ;
246
246
it ( 'throws error when ref is a deep circular reference in a bundled JSON Schema' , ( ) => {
247
- expect ( ( ) => findSchemaDefinition ( '#/$defs/circularRef' , bundledSchema ) ) . toThrowError (
247
+ expect ( ( ) => findSchemaDefinition ( '#/$defs/circularRef' , bundledSchema ) ) . toThrow (
248
248
'Definition for #/$defs/circularRef contains a circular reference through /bundled.ref.json/#/$defs/circularRef -> /bundled.schema.json/#/$defs/circularRef -> #/$defs/circularRef' ,
249
249
) ;
250
250
} ) ;
251
251
} ) ;
252
252
253
253
describe ( 'findSchemaDefinitionRecursive()' , ( ) => {
254
254
it ( 'throws error when ref is missing' , ( ) => {
255
- expect ( ( ) => findSchemaDefinitionRecursive ( ) ) . toThrowError ( 'Could not find a definition for undefined' ) ;
255
+ expect ( ( ) => findSchemaDefinitionRecursive ( ) ) . toThrow ( 'Could not find a definition for undefined' ) ;
256
256
} ) ;
257
257
it ( 'throws error when ref is malformed' , ( ) => {
258
- expect ( ( ) => findSchemaDefinitionRecursive ( 'definitions/missing' ) ) . toThrowError (
258
+ expect ( ( ) => findSchemaDefinitionRecursive ( 'definitions/missing' ) ) . toThrow (
259
259
'Could not find a definition for definitions/missing' ,
260
260
) ;
261
261
} ) ;
262
262
it ( 'throws error when ref does not exist' , ( ) => {
263
- expect ( ( ) => findSchemaDefinitionRecursive ( '#/definitions/missing' , schema ) ) . toThrowError (
263
+ expect ( ( ) => findSchemaDefinitionRecursive ( '#/definitions/missing' , schema ) ) . toThrow (
264
264
'Could not find a definition for #/definitions/missing' ,
265
265
) ;
266
266
} ) ;
@@ -274,24 +274,24 @@ describe('findSchemaDefinitionRecursive()', () => {
274
274
expect ( findSchemaDefinitionRecursive ( '#/definitions/extraNestedRef' , schema ) ) . toEqual ( EXTRA_EXPECTED ) ;
275
275
} ) ;
276
276
it ( 'throws error when ref is a circular reference' , ( ) => {
277
- expect ( ( ) => findSchemaDefinitionRecursive ( '#/definitions/badCircularNestedRef' , schema ) ) . toThrowError (
277
+ expect ( ( ) => findSchemaDefinitionRecursive ( '#/definitions/badCircularNestedRef' , schema ) ) . toThrow (
278
278
'Definition for #/definitions/badCircularNestedRef is a circular reference' ,
279
279
) ;
280
280
} ) ;
281
281
it ( 'throws error when ref is a deep circular reference' , ( ) => {
282
- expect ( ( ) => findSchemaDefinitionRecursive ( '#/definitions/badCircularDeepNestedRef' , schema ) ) . toThrowError (
282
+ expect ( ( ) => findSchemaDefinitionRecursive ( '#/definitions/badCircularDeepNestedRef' , schema ) ) . toThrow (
283
283
'Definition for #/definitions/badCircularDeepNestedRef contains a circular reference through #/definitions/badCircularDeeperNestedRef -> #/definitions/badCircularDeepestNestedRef -> #/definitions/badCircularDeepNestedRef' ,
284
284
) ;
285
285
} ) ;
286
286
it ( 'throws error when bundled ref are not part of JSON Schema Draft 2020-12' , ( ) => {
287
- expect ( ( ) => findSchemaDefinitionRecursive ( '#/definitions/bundledRef' , schema ) ) . toThrowError (
287
+ expect ( ( ) => findSchemaDefinitionRecursive ( '#/definitions/bundledRef' , schema ) ) . toThrow (
288
288
'Could not find a definition for /bundled.ref.json' ,
289
289
) ;
290
290
} ) ;
291
291
it ( 'throws error when bundled ref with explicit baseURI are not part of JSON Schema Draft 2020-12' , ( ) => {
292
292
expect ( ( ) =>
293
293
findSchemaDefinitionRecursive ( '#/properties/num' , schema , [ ] , 'https://example.com/bundled.ref.json' ) ,
294
- ) . toThrowError ( 'Could not find a definition for #/properties/num' ) ;
294
+ ) . toThrow ( 'Could not find a definition for #/properties/num' ) ;
295
295
} ) ;
296
296
it ( 'correctly resolves absolute bundled refs within a JSON Schema Draft 2020-12' , ( ) => {
297
297
expect ( findSchemaDefinitionRecursive ( '#/$defs/bundledAbsoluteRef' , bundledSchema ) ) . toStrictEqual ( internalSchema ) ;
@@ -334,12 +334,12 @@ describe('findSchemaDefinitionRecursive()', () => {
334
334
) . toBe ( internalSchema . properties ! . num ) ;
335
335
} ) ;
336
336
it ( 'throws error when relative ref is undefined in a bundled JSON Schema' , ( ) => {
337
- expect ( ( ) => findSchemaDefinitionRecursive ( '#/$defs/undefinedRef' , bundledSchema ) ) . toThrowError (
337
+ expect ( ( ) => findSchemaDefinitionRecursive ( '#/$defs/undefinedRef' , bundledSchema ) ) . toThrow (
338
338
'Could not find a definition for /undefined.ref.json' ,
339
339
) ;
340
340
} ) ;
341
341
it ( 'throws error when relative ref with anchor is undefined in a bundled JSON Schema' , ( ) => {
342
- expect ( ( ) => findSchemaDefinitionRecursive ( '#/$defs/undefinedRefWithAnchor' , bundledSchema ) ) . toThrowError (
342
+ expect ( ( ) => findSchemaDefinitionRecursive ( '#/$defs/undefinedRefWithAnchor' , bundledSchema ) ) . toThrow (
343
343
'Could not find a definition for #/$defs/undefined' ,
344
344
) ;
345
345
} ) ;
@@ -351,15 +351,15 @@ describe('findSchemaDefinitionRecursive()', () => {
351
351
[ ] ,
352
352
'https://example.com/bundled.ref.json' ,
353
353
) ,
354
- ) . toThrowError ( 'Could not find a definition for #/properties/undefined' ) ;
354
+ ) . toThrow ( 'Could not find a definition for #/properties/undefined' ) ;
355
355
} ) ;
356
356
it ( 'throws error when explicit base URI is undefined in a bundled JSON Schema' , ( ) => {
357
357
expect ( ( ) =>
358
358
findSchemaDefinition ( '#/properties/undefined' , bundledSchema , 'https://example.com/undefined.ref.json' ) ,
359
- ) . toThrowError ( 'Could not find a definition for #/properties/undefined' ) ;
359
+ ) . toThrow ( 'Could not find a definition for #/properties/undefined' ) ;
360
360
} ) ;
361
361
it ( 'throws error when ref is a deep circular reference in a bundled JSON Schema' , ( ) => {
362
- expect ( ( ) => findSchemaDefinitionRecursive ( '#/$defs/circularRef' , bundledSchema , [ ] ) ) . toThrowError (
362
+ expect ( ( ) => findSchemaDefinitionRecursive ( '#/$defs/circularRef' , bundledSchema , [ ] ) ) . toThrow (
363
363
'Definition for #/$defs/circularRef contains a circular reference through /bundled.ref.json/#/$defs/circularRef -> /bundled.schema.json/#/$defs/circularRef -> #/$defs/circularRef' ,
364
364
) ;
365
365
} ) ;
0 commit comments