@@ -243,105 +243,55 @@ o.spec('LINZ collection', () => {
243
243
}
244
244
} ) ;
245
245
246
- o ( "Asset summary created/updated without the mandatory 'minimum' property should fail validation" , async ( ) => {
247
- for ( const property of [ 'created' , 'updated' ] ) {
248
- // given
249
- const example = JSON . parse ( await fs . readFile ( examplePath ) ) ;
250
- delete example [ 'linz:asset_summaries' ] [ property ] [ 'minimum' ] ;
251
-
252
- // when
253
- let valid = validate ( example ) ;
254
-
255
- // then
256
- o ( valid ) . equals ( false ) ;
257
- o (
258
- validate . errors . some (
259
- ( error ) =>
260
- error . instancePath === `/linz:asset_summaries/${ property } ` &&
261
- error . message === "must have required property 'minimum'" ,
262
- ) ,
263
- ) . equals ( true ) ( JSON . stringify ( validate . errors ) ) ;
264
- }
265
- } ) ;
266
-
267
- o ( "Asset summary created without the mandatory 'maximum' property should fail validation" , async ( ) => {
268
- // given
269
- const example = JSON . parse ( await fs . readFile ( examplePath ) ) ;
270
- delete example [ 'linz:asset_summaries' ] [ 'created' ] [ 'maximum' ] ;
271
-
272
- // when
273
- let valid = validate ( example ) ;
274
-
275
- // then
276
- o ( valid ) . equals ( false ) ;
277
- o (
278
- validate . errors . some (
279
- ( error ) =>
280
- error . instancePath === '/linz:asset_summaries/created' &&
281
- error . message === "must have required property 'maximum'" ,
282
- ) ,
283
- ) . equals ( true ) ( JSON . stringify ( validate . errors ) ) ;
284
- } ) ;
285
-
286
- o ( "Asset summary updated without the mandatory 'maximum' property should fail validation" , async ( ) => {
287
- // given
288
- const example = JSON . parse ( await fs . readFile ( examplePath ) ) ;
289
- delete example [ 'linz:asset_summaries' ] [ 'updated' ] [ 'maximum' ] ;
290
-
291
- // when
292
- let valid = validate ( example ) ;
293
-
294
- // then
295
- o ( valid ) . equals ( false ) ;
296
- o (
297
- validate . errors . some (
298
- ( error ) =>
299
- error . dataPath === "['linz:asset_summaries'].updated" &&
300
- error . message === "should have required property '.maximum'" ,
301
- ) ,
302
- ) . equals ( true ) ( JSON . stringify ( validate . errors ) ) ;
303
- } ) ;
304
-
305
- o ( "Asset summary created/updated with invalid 'minimum' value should fail validation" , async ( ) => {
306
- for ( const property of [ 'created' , 'updated' ] ) {
307
- // given
308
- const example = JSON . parse ( await fs . readFile ( examplePath ) ) ;
309
- example [ 'linz:asset_summaries' ] [ property ] [ 'minimum' ] = '1999-01-01T00:00:00' ;
310
-
311
- // when
312
- let valid = validate ( example ) ;
313
-
314
- // then
315
- o ( valid ) . equals ( false ) ;
316
- o (
317
- validate . errors . some (
318
- ( error ) =>
319
- error . instancePath === `/linz:asset_summaries/${ property } /minimum` &&
320
- error . message === 'must match pattern "(\\+00:00|Z)$"' ,
321
- ) ,
322
- ) . equals ( true ) ( JSON . stringify ( validate . errors ) ) ;
246
+ o (
247
+ "Asset summary created/updated without the mandatory 'minimum'/'maximum' properties should fail validation" ,
248
+ async ( ) => {
249
+ for ( const outerProperty of [ 'created' , 'updated' ] ) {
250
+ for ( const innerProperty of [ 'minimum' , 'maximum' ] ) {
251
+ // given
252
+ const example = JSON . parse ( await fs . readFile ( examplePath ) ) ;
253
+ delete example [ 'linz:asset_summaries' ] [ outerProperty ] [ innerProperty ] ;
254
+
255
+ // when
256
+ let valid = validate ( example ) ;
257
+
258
+ // then
259
+ o ( valid ) . equals ( false ) ;
260
+ o (
261
+ validate . errors . some (
262
+ ( error ) =>
263
+ error . instancePath === `/linz:asset_summaries/${ outerProperty } ` &&
264
+ error . message === `must have required property '${ innerProperty } '` ,
265
+ ) ,
266
+ ) . equals ( true ) ( JSON . stringify ( validate . errors ) ) ;
267
+ }
268
+ }
269
+ } ,
270
+ ) ;
271
+
272
+ o ( "Asset summary created/updated with invalid 'minimum'/'maximum' value should fail validation" , async ( ) => {
273
+ for ( const outerProperty of [ 'created' , 'updated' ] ) {
274
+ for ( const innerProperty of [ 'minimum' , 'maximum' ] ) {
275
+ // given
276
+ const example = JSON . parse ( await fs . readFile ( examplePath ) ) ;
277
+ example [ 'linz:asset_summaries' ] [ outerProperty ] [ innerProperty ] = '1999-01-01T00:00:00' ;
278
+
279
+ // when
280
+ let valid = validate ( example ) ;
281
+
282
+ // then
283
+ o ( valid ) . equals ( false ) ;
284
+ o (
285
+ validate . errors . some (
286
+ ( error ) =>
287
+ error . instancePath === `/linz:asset_summaries/${ outerProperty } /${ innerProperty } ` &&
288
+ error . message === 'must match pattern "(\\+00:00|Z)$"' ,
289
+ ) ,
290
+ ) . equals ( true ) ( JSON . stringify ( validate . errors ) ) ;
291
+ }
323
292
}
324
293
} ) ;
325
294
326
- o ( "Asset summary created with invalid 'maximum' value should fail validation" , async ( ) => {
327
- // given
328
- const example = JSON . parse ( await fs . readFile ( examplePath ) ) ;
329
- example [ 'linz:asset_summaries' ] [ 'created' ] [ 'maximum' ] = '1999-01-01T00:00:00' ;
330
-
331
- // when
332
- let valid = validate ( example ) ;
333
-
334
- // then
335
- o ( valid ) . equals ( false ) ;
336
- o (
337
- validate . errors . some (
338
- ( error ) =>
339
- error . instancePath === '/linz:asset_summaries/created/maximum' &&
340
- error . message === 'must match pattern "(\\+00:00|Z)$"' ,
341
- ) ,
342
- ) . equals ( true ) ( JSON . stringify ( validate . errors ) ) ;
343
- } ) ;
344
-
345
295
o ( "Example without the mandatory 'linz:history' field should fail validation" , async ( ) => {
346
296
// given
347
297
const example = JSON . parse ( await fs . readFile ( examplePath ) ) ;
0 commit comments