@@ -402,4 +402,89 @@ describe('cloneDeep', () => {
402
402
expect ( clonedInstance . value ) . toBe ( instance . value ) ;
403
403
expect ( clonedInstance . getValue ( ) ) . toBe ( 123 ) ;
404
404
} ) ;
405
+
406
+ it ( 'should clone arguments objects' , ( ) => {
407
+ function func ( ) {
408
+ // eslint-disable-next-line prefer-rest-params
409
+ return cloneDeep ( arguments ) ;
410
+ }
411
+ // @ts -expect-error: arguments object allows calling with parameters despite no formal params
412
+ const args = func ( 1 , 2 , 3 ) ;
413
+ const cloned = cloneDeep ( args ) ;
414
+
415
+ expect ( cloned ) . toEqual ( args ) ;
416
+ expect ( cloned ) . not . toBe ( args ) ;
417
+ } ) ;
418
+
419
+ it ( 'should clone Boolean objects' , ( ) => {
420
+ const boolObj = new Boolean ( true ) ;
421
+ const cloned = cloneDeep ( boolObj ) ;
422
+
423
+ expect ( cloned ) . toEqual ( boolObj ) ;
424
+ expect ( cloned ) . not . toBe ( boolObj ) ;
425
+ expect ( cloned ) . toBeInstanceOf ( Boolean ) ;
426
+ } ) ;
427
+
428
+ it ( 'should clone String objects' , ( ) => {
429
+ const strObj = new String ( 'es-toolkit' ) ;
430
+ const cloned = cloneDeep ( strObj ) ;
431
+
432
+ expect ( cloned ) . toEqual ( strObj ) ;
433
+ expect ( cloned ) . not . toBe ( strObj ) ;
434
+ expect ( cloned ) . toBeInstanceOf ( String ) ;
435
+ } ) ;
436
+
437
+ it ( 'should clone Number objects' , ( ) => {
438
+ const numObj = new Number ( 42 ) ;
439
+ const cloned = cloneDeep ( numObj ) ;
440
+
441
+ expect ( cloned ) . toEqual ( numObj ) ;
442
+ expect ( cloned ) . not . toBe ( numObj ) ;
443
+ expect ( cloned ) . toBeInstanceOf ( Number ) ;
444
+ } ) ;
445
+
446
+ it ( 'should clone Float32Array' , ( ) => {
447
+ const arr = new Float32Array ( [ 1.1 , 2.2 , 3.3 ] ) ;
448
+ const cloned = cloneDeep ( arr ) ;
449
+
450
+ expect ( cloned ) . toEqual ( arr ) ;
451
+ expect ( cloned ) . not . toBe ( arr ) ;
452
+ expect ( cloned ) . toBeInstanceOf ( Float32Array ) ;
453
+ } ) ;
454
+
455
+ it ( 'should clone Float64Array' , ( ) => {
456
+ const arr = new Float64Array ( [ 1.1 , 2.2 , 3.3 ] ) ;
457
+ const cloned = cloneDeep ( arr ) ;
458
+
459
+ expect ( cloned ) . toEqual ( arr ) ;
460
+ expect ( cloned ) . not . toBe ( arr ) ;
461
+ expect ( cloned ) . toBeInstanceOf ( Float64Array ) ;
462
+ } ) ;
463
+
464
+ it ( 'should clone Int8Array' , ( ) => {
465
+ const arr = new Int8Array ( [ 1 , 2 , 3 ] ) ;
466
+ const cloned = cloneDeep ( arr ) ;
467
+
468
+ expect ( cloned ) . toEqual ( arr ) ;
469
+ expect ( cloned ) . not . toBe ( arr ) ;
470
+ expect ( cloned ) . toBeInstanceOf ( Int8Array ) ;
471
+ } ) ;
472
+
473
+ it ( 'should clone Int16Array' , ( ) => {
474
+ const arr = new Int16Array ( [ 1 , 2 , 3 ] ) ;
475
+ const cloned = cloneDeep ( arr ) ;
476
+
477
+ expect ( cloned ) . toEqual ( arr ) ;
478
+ expect ( cloned ) . not . toBe ( arr ) ;
479
+ expect ( cloned ) . toBeInstanceOf ( Int16Array ) ;
480
+ } ) ;
481
+
482
+ it ( 'should clone Int32Array' , ( ) => {
483
+ const arr = new Int32Array ( [ 1 , 2 , 3 ] ) ;
484
+ const cloned = cloneDeep ( arr ) ;
485
+
486
+ expect ( cloned ) . toEqual ( arr ) ;
487
+ expect ( cloned ) . not . toBe ( arr ) ;
488
+ expect ( cloned ) . toBeInstanceOf ( Int32Array ) ;
489
+ } ) ;
405
490
} ) ;
0 commit comments