You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/index.spec.ts
+96Lines changed: 96 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,10 @@ describe('index', () => {
41
41
);
42
42
});
43
43
44
+
it('parse required error but should not validate',()=>{
45
+
expect(parameters.parse({},false)).toEqual({});
46
+
});
47
+
44
48
it('stringify',()=>{
45
49
expect(
46
50
parameters.stringify({
@@ -69,6 +73,10 @@ describe('index', () => {
69
73
'stringValue is required, unionStringValue is required, numberValue is required, unionNumberValue is required, booleanValue is required, jsonValue is required, arrayValue is required.'
70
74
);
71
75
});
76
+
77
+
it('stringify required error but should not validate',()=>{
it('parse validation error but should not validate',()=>{
413
+
expect(
414
+
parameters.parse(
415
+
{
416
+
stringValue: 'yyyy',
417
+
unionStringValue: 'v3',
418
+
numberValue: '0',
419
+
unionNumberValue: '-1',
420
+
booleanValue: 'false',
421
+
jsonValue: '{"apiKey":""}',
422
+
arrayValue: '[]',
423
+
},
424
+
false
425
+
)
426
+
).toEqual({
427
+
arrayValue: [],
428
+
booleanValue: false,
429
+
jsonValue: {
430
+
apiKey: '',
431
+
},
432
+
numberValue: 0,
433
+
stringValue: 'yyyy',
434
+
unionNumberValue: -1,
435
+
unionStringValue: 'v3',
436
+
});
437
+
});
438
+
404
439
it('parse required error and validation error',()=>{
405
440
expect(()=>
406
441
parameters.parse({
@@ -414,6 +449,25 @@ describe('index', () => {
414
449
);
415
450
});
416
451
452
+
it('parse required error and validation error, but should not validaet',()=>{
453
+
expect(
454
+
parameters.parse(
455
+
{
456
+
stringValue: 'yyyy',
457
+
numberValue: '0',
458
+
booleanValue: 'false',
459
+
arrayValue: '[]',
460
+
},
461
+
false
462
+
)
463
+
).toEqual({
464
+
stringValue: 'yyyy',
465
+
numberValue: 0,
466
+
booleanValue: false,
467
+
arrayValue: [],
468
+
});
469
+
});
470
+
417
471
it('stringify',()=>{
418
472
expect(
419
473
parameters.stringify({
@@ -463,6 +517,31 @@ describe('index', () => {
463
517
);
464
518
});
465
519
520
+
it('stringify validation error but should not validate',()=>{
521
+
expect(
522
+
parameters.stringify(
523
+
{
524
+
stringValue: 'yyyy',
525
+
unionStringValue: 'v3'asnever,
526
+
numberValue: 0,
527
+
unionNumberValue: -1asnever,
528
+
booleanValue: false,
529
+
jsonValue: {apiKey: ''},
530
+
arrayValue: [],
531
+
},
532
+
false
533
+
)
534
+
).toEqual({
535
+
stringValue: 'yyyy',
536
+
unionStringValue: 'v3',
537
+
numberValue: '0',
538
+
unionNumberValue: '-1',
539
+
booleanValue: 'false',
540
+
jsonValue: '{"apiKey":""}',
541
+
arrayValue: '[]',
542
+
});
543
+
});
544
+
466
545
it('stringify required error and validation error',()=>{
467
546
expect(()=>
468
547
parameters.stringify({
@@ -474,5 +553,22 @@ describe('index', () => {
474
553
'stringValue is required, numberValue is required, booleanValue is required, arrayValue is required. unionStringValue: the value must be v1 or v2, unionNumberValue: the value must be 0 or 1, jsonValue: apiKey must be specified.'
475
554
);
476
555
});
556
+
557
+
it('stringify required error and validation error, but should not validate',()=>{
0 commit comments