@@ -346,13 +346,17 @@ test('replacer removing all elements and indentation', function (assert) {
346
346
test ( 'array replacer' , function ( assert ) {
347
347
const replacer = [ 'f' , 1 , null ]
348
348
const obj = { f : null , null : true , 1 : false }
349
- // The null element will be removed!
349
+ // The null element will be ignored!
350
+ // @ts -expect-error
350
351
const expected = JSON . stringify ( obj , replacer )
352
+ // @ts -expect-error
351
353
let actual = stringify ( obj , replacer )
352
354
assert . equal ( actual , expected )
353
355
356
+ // @ts -expect-error
354
357
obj . f = obj
355
358
359
+ // @ts -expect-error
356
360
actual = stringify ( { toJSON ( ) { return obj } } , replacer )
357
361
assert . equal ( actual , expected . replace ( 'null' , '"[Circular]"' ) )
358
362
@@ -374,7 +378,9 @@ test('array replacer and indentation', function (assert) {
374
378
const replacer = [ 'f' , 1 , null ]
375
379
const obj = { f : null , null : true , 1 : [ false , - Infinity , 't' ] }
376
380
// The null element will be removed!
381
+ // @ts -expect-error
377
382
const expected = JSON . stringify ( obj , replacer , 2 )
383
+ // @ts -expect-error
378
384
const actual = stringify ( obj , replacer , 2 )
379
385
assert . equal ( actual , expected )
380
386
assert . end ( )
@@ -484,16 +490,16 @@ test('object with undefined values', function (assert) {
484
490
} )
485
491
486
492
test ( 'undefined values and indented' , function ( assert ) {
487
- let obj = { a : 1 , c : undefined , b : 'hello' }
493
+ const obj1 = { a : 1 , c : undefined , b : 'hello' }
488
494
489
- let expected = JSON . stringify ( obj , null , 2 )
490
- let actual = stringify ( obj , null , 2 )
495
+ let expected = JSON . stringify ( obj1 , null , 2 )
496
+ let actual = stringify ( obj1 , null , 2 )
491
497
assert . equal ( actual , expected )
492
498
493
- obj = { b : 'hello' , a : undefined , c : 1 }
499
+ const obj2 = { b : 'hello' , a : undefined , c : 1 }
494
500
495
- expected = JSON . stringify ( obj )
496
- actual = stringify ( obj )
501
+ expected = JSON . stringify ( obj2 )
502
+ actual = stringify ( obj2 )
497
503
assert . equal ( actual , expected )
498
504
499
505
assert . end ( )
@@ -516,6 +522,7 @@ test('bigint option', function (assert) {
516
522
assert . equal ( actualBigInt , expectedBigInt )
517
523
assert . equal ( actualDefault , expectedBigInt )
518
524
525
+ // @ts -expect-error
519
526
assert . throws ( ( ) => stringify . configure ( { bigint : null } ) , / b i g i n t / )
520
527
521
528
assert . end ( )
@@ -620,11 +627,11 @@ test('non-deterministic with replacer', function (assert) {
620
627
const keys = Object . keys ( obj )
621
628
622
629
const expected = stringify ( obj , [ 'b' , 'c' , 'd' , 'e' ] )
623
- let actual = stringifyNonDeterministic ( obj , keys )
624
- assert . equal ( actual , expected )
630
+ const actualA = stringifyNonDeterministic ( obj , keys )
631
+ assert . equal ( actualA , expected )
625
632
626
- actual = stringifyNonDeterministic ( obj , ( k , v ) => v )
627
- assert . equal ( actual , expected )
633
+ const actualB = stringifyNonDeterministic ( obj , ( k , v ) => v )
634
+ assert . equal ( actualB , expected )
628
635
629
636
assert . end ( )
630
637
} )
@@ -654,20 +661,20 @@ test('check small typed arrays with extra properties', function (assert) {
654
661
// @ts -expect-error
655
662
obj . foo = true
656
663
let expected = JSON . stringify ( obj )
657
- let actual = stringify ( obj )
658
- assert . equal ( actual , expected )
664
+ const actualA = stringify ( obj )
665
+ assert . equal ( actualA , expected )
659
666
660
667
expected = JSON . stringify ( obj , null , 2 )
661
- actual = stringify ( obj , null , 2 )
662
- assert . equal ( actual , expected )
668
+ const actualB = stringify ( obj , null , 2 )
669
+ assert . equal ( actualB , expected )
663
670
664
671
expected = JSON . stringify ( obj , [ 'foo' ] )
665
- actual = stringify ( obj , [ 'foo' ] )
666
- assert . equal ( actual , expected )
672
+ const actualC = stringify ( obj , [ 'foo' ] )
673
+ assert . equal ( actualC , expected )
667
674
668
675
expected = JSON . stringify ( obj , ( a , b ) => b )
669
- actual = stringify ( obj , ( a , b ) => b )
670
- assert . equal ( actual , expected )
676
+ const actualD = stringify ( obj , ( a , b ) => b )
677
+ assert . equal ( actualD , expected )
671
678
672
679
assert . end ( )
673
680
} )
@@ -972,26 +979,26 @@ test('show skipped keys even non were serliazable', (assert) => {
972
979
973
980
const input = { a : Symbol ( 'ignored' ) , b : Symbol ( 'ignored' ) }
974
981
975
- let actual = serialize ( input )
982
+ const actual1 = serialize ( input )
976
983
let expected = '{"...":"1 item not stringified"}'
977
- assert . equal ( actual , expected )
984
+ assert . equal ( actual1 , expected )
978
985
979
- actual = serialize ( input , ( a , b ) => b )
980
- assert . equal ( actual , expected )
986
+ const actual2 = serialize ( input , ( a , b ) => b )
987
+ assert . equal ( actual2 , expected )
981
988
982
- actual = serialize ( input , null , 1 )
989
+ const actual3 = serialize ( input , null , 1 )
983
990
expected = '{\n "...": "1 item not stringified"\n}'
984
- assert . equal ( actual , expected )
991
+ assert . equal ( actual3 , expected )
985
992
986
- actual = serialize ( input , ( a , b ) => b , 1 )
987
- assert . equal ( actual , expected )
993
+ const actual4 = serialize ( input , ( a , b ) => b , 1 )
994
+ assert . equal ( actual4 , expected )
988
995
989
- actual = serialize ( input , [ 'a' ] )
996
+ const actual5 = serialize ( input , [ 'a' ] )
990
997
expected = '{}'
991
- assert . equal ( actual , expected )
998
+ assert . equal ( actual5 , expected )
992
999
993
- actual = serialize ( input , [ 'a' , 'b' , 'c' ] )
994
- assert . equal ( actual , expected )
1000
+ const actual6 = serialize ( input , [ 'a' , 'b' , 'c' ] )
1001
+ assert . equal ( actual6 , expected )
995
1002
996
1003
assert . end ( )
997
1004
} )
0 commit comments