@@ -2,11 +2,11 @@ import test from 'ava';
2
2
import { checkValidationFailure , checkValidationSuccess } from '../test-libraries/verify-schema-validation.js' ;
3
3
import { packtoryConfigSchema } from './config.js' ;
4
4
5
- test ( 'validation succeeds when commonPackageSettings is undefined ' , checkValidationSuccess , {
5
+ test ( 'validation succeeds when commonPackageSettings is defined but empty ' , checkValidationSuccess , {
6
6
schema : packtoryConfigSchema ,
7
7
data : {
8
8
registrySettings : { token : 'foo' } ,
9
- commonPackageSettings : undefined ,
9
+ commonPackageSettings : { } ,
10
10
packages : [
11
11
{
12
12
sourcesFolder : 'source' ,
@@ -18,6 +18,25 @@ test('validation succeeds when commonPackageSettings is undefined', checkValidat
18
18
}
19
19
} ) ;
20
20
21
+ test ( 'validation succeeds when commonPackageSettings is defined with all optional values' , checkValidationSuccess , {
22
+ schema : packtoryConfigSchema ,
23
+ data : {
24
+ registrySettings : { token : 'foo' } ,
25
+ commonPackageSettings : {
26
+ includeSourceMapFiles : true ,
27
+ additionalFiles : [ ] ,
28
+ additionalPackageJsonAttributes : { }
29
+ } ,
30
+ packages : [
31
+ {
32
+ sourcesFolder : 'source' ,
33
+ mainPackageJson : { } ,
34
+ name : 'foo' ,
35
+ entryPoints : [ { js : 'foo' } ]
36
+ }
37
+ ]
38
+ }
39
+ } ) ;
21
40
test (
22
41
'validation succeeds when commonPackageSettings is not given and a package contains all required settings' ,
23
42
checkValidationSuccess ,
@@ -204,13 +223,12 @@ test('validation fails when an empty object is given', checkValidationFailure, {
204
223
} ) ;
205
224
206
225
test (
207
- 'validation fails when commonPackageSettings is undefined and mainPackageJson is missing in a package' ,
226
+ 'validation fails when commonPackageSettings is not defined and mainPackageJson is missing in a package' ,
208
227
checkValidationFailure ,
209
228
{
210
229
schema : packtoryConfigSchema ,
211
230
data : {
212
231
registrySettings : { token : 'foo' } ,
213
- commonPackageSettings : undefined ,
214
232
packages : [
215
233
{
216
234
sourcesFolder : 'source' ,
@@ -221,7 +239,7 @@ test(
221
239
} ,
222
240
expectedMessages : [
223
241
'At packages.0.mainPackageJson: missing key or index' ,
224
- 'At commonPackageSettings: expected object; but got undefined '
242
+ 'At commonPackageSettings: missing key or index '
225
243
]
226
244
}
227
245
) ;
@@ -235,26 +253,29 @@ test('validation fails when packages is an empty array', checkValidationFailure,
235
253
expectedMessages : [ 'At packages.0: missing key or index' , 'At commonPackageSettings: missing key or index' ]
236
254
} ) ;
237
255
238
- test ( 'validation fails when commonPackageSettings is empty' , checkValidationFailure , {
239
- schema : packtoryConfigSchema ,
240
- data : {
241
- registrySettings : { token : 'foo' } ,
242
- commonPackageSettings : { } ,
243
- packages : [
244
- {
245
- name : 'foo' ,
246
- entryPoints : [ { js : 'foo' } ]
247
- }
256
+ test (
257
+ 'validation fails when commonPackageSettings is empty and packages don’t define required properties' ,
258
+ checkValidationFailure ,
259
+ {
260
+ schema : packtoryConfigSchema ,
261
+ data : {
262
+ registrySettings : { token : 'foo' } ,
263
+ commonPackageSettings : { } ,
264
+ packages : [
265
+ {
266
+ name : 'foo' ,
267
+ entryPoints : [ { js : 'foo' } ]
268
+ }
269
+ ]
270
+ } ,
271
+ expectedMessages : [
272
+ 'At packages.0.sourcesFolder: missing key or index' ,
273
+ 'At packages.0.mainPackageJson: missing key or index' ,
274
+ 'At commonPackageSettings.sourcesFolder: missing key or index' ,
275
+ 'At commonPackageSettings.mainPackageJson: missing key or index'
248
276
]
249
- } ,
250
- expectedMessages : [
251
- 'At commonPackageSettings: expected undefined; but got object' ,
252
- 'At packages.0.sourcesFolder: missing key or index' ,
253
- 'At packages.0.mainPackageJson: missing key or index' ,
254
- 'At commonPackageSettings.sourcesFolder: missing key or index' ,
255
- 'At commonPackageSettings.mainPackageJson: missing key or index'
256
- ]
257
- } ) ;
277
+ }
278
+ ) ;
258
279
259
280
test ( 'validation fails when commonPackageSettings contains only mainPackageJson' , checkValidationFailure , {
260
281
schema : packtoryConfigSchema ,
@@ -271,7 +292,6 @@ test('validation fails when commonPackageSettings contains only mainPackageJson'
271
292
]
272
293
} ,
273
294
expectedMessages : [
274
- 'At commonPackageSettings: expected undefined; but got object' ,
275
295
'At packages.0.sourcesFolder: missing key or index' ,
276
296
'At packages.0.mainPackageJson: missing key or index' ,
277
297
'At commonPackageSettings.sourcesFolder: missing key or index'
@@ -295,8 +315,8 @@ test(
295
315
]
296
316
} ,
297
317
expectedMessages : [
298
- 'At packages.0.sourcesFolder: missing key or index ' ,
299
- 'At commonPackageSettings: expected object; but got undefined '
318
+ 'At commonPackageSettings: expected object; but got undefined ' ,
319
+ 'At packages.0.sourcesFolder: missing key or index '
300
320
]
301
321
}
302
322
) ;
@@ -316,7 +336,6 @@ test('validation fails when commonPackageSettings contains only sourcesFolder',
316
336
]
317
337
} ,
318
338
expectedMessages : [
319
- 'At commonPackageSettings: expected undefined; but got object' ,
320
339
'At packages.0.sourcesFolder: missing key or index' ,
321
340
'At packages.0.mainPackageJson: missing key or index' ,
322
341
'At commonPackageSettings.mainPackageJson: missing key or index'
@@ -450,10 +469,9 @@ test('validation fails when additionalFiles is not an array', checkValidationFai
450
469
]
451
470
} ,
452
471
expectedMessages : [
453
- 'At commonPackageSettings: expected undefined ; but got object ' ,
472
+ 'At commonPackageSettings.additionalFiles : expected array ; but got string ' ,
454
473
'At packages.0.sourcesFolder: missing key or index' ,
455
- 'At packages.0.mainPackageJson: missing key or index' ,
456
- 'At commonPackageSettings.additionalFiles: expected array; but got string'
474
+ 'At packages.0.mainPackageJson: missing key or index'
457
475
]
458
476
} ) ;
459
477
@@ -474,10 +492,9 @@ test('validation fails when includeSourceMapFiles is not a boolean', checkValida
474
492
]
475
493
} ,
476
494
expectedMessages : [
477
- 'At commonPackageSettings: expected undefined ; but got object ' ,
495
+ 'At commonPackageSettings.includeSourceMapFiles : expected boolean ; but got string ' ,
478
496
'At packages.0.sourcesFolder: missing key or index' ,
479
- 'At packages.0.mainPackageJson: missing key or index' ,
480
- 'At commonPackageSettings.includeSourceMapFiles: expected boolean; but got string'
497
+ 'At packages.0.mainPackageJson: missing key or index'
481
498
]
482
499
} ) ;
483
500
@@ -498,10 +515,9 @@ test('validation fails when additionalPackageJsonAttributes is not an object', c
498
515
]
499
516
} ,
500
517
expectedMessages : [
501
- 'At commonPackageSettings: expected undefined ; but got object ' ,
518
+ 'At commonPackageSettings.additionalPackageJsonAttributes : expected object ; but got string ' ,
502
519
'At packages.0.sourcesFolder: missing key or index' ,
503
- 'At packages.0.mainPackageJson: missing key or index' ,
504
- 'At commonPackageSettings.additionalPackageJsonAttributes: expected object; but got string'
520
+ 'At packages.0.mainPackageJson: missing key or index'
505
521
]
506
522
} ) ;
507
523
@@ -522,7 +538,6 @@ test('validation fails when versioning is not an object', checkValidationFailure
522
538
]
523
539
} ,
524
540
expectedMessages : [
525
- 'At commonPackageSettings: expected undefined; but got object' ,
526
541
'At packages.0.sourcesFolder: missing key or index' ,
527
542
'At packages.0.mainPackageJson: missing key or index' ,
528
543
'At packages.0.versioning: expected object; but got string'
@@ -546,7 +561,6 @@ test('validation fails when bundleDependencies is not an array', checkValidation
546
561
]
547
562
} ,
548
563
expectedMessages : [
549
- 'At commonPackageSettings: expected undefined; but got object' ,
550
564
'At packages.0.sourcesFolder: missing key or index' ,
551
565
'At packages.0.mainPackageJson: missing key or index' ,
552
566
'At packages.0.bundleDependencies: expected array; but got string'
@@ -570,7 +584,6 @@ test('validation fails when bundlePeerDependencies is not an array', checkValida
570
584
]
571
585
} ,
572
586
expectedMessages : [
573
- 'At commonPackageSettings: expected undefined; but got object' ,
574
587
'At packages.0.sourcesFolder: missing key or index' ,
575
588
'At packages.0.mainPackageJson: missing key or index' ,
576
589
'At packages.0.bundlePeerDependencies: expected array; but got string'
0 commit comments