File tree 1 file changed +36
-2
lines changed
1 file changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,14 @@ var undef = {
44
44
arr : [ 1 , 2 , undefined ]
45
45
} ;
46
46
47
+ var undef2 = {
48
+ str : undefined ,
49
+ layer : {
50
+ date : undefined
51
+ } ,
52
+ arr : [ 1 , undefined , 2 ]
53
+ } ;
54
+
47
55
48
56
describe ( 'extendFlat' , function ( ) {
49
57
'use strict' ;
@@ -376,7 +384,7 @@ describe('extendDeep', function() {
376
384
377
385
expect ( ori ) . toEqual ( {
378
386
layer : { } ,
379
- arr : [ 1 , 2 ]
387
+ arr : [ 1 , 2 ]
380
388
} ) ;
381
389
expect ( undef ) . toEqual ( {
382
390
str : undefined ,
@@ -387,7 +395,33 @@ describe('extendDeep', function() {
387
395
} ) ;
388
396
expect ( target ) . toEqual ( {
389
397
layer : { } ,
390
- arr : [ 1 , 2 ]
398
+ arr : [ 1 , 2 ]
399
+ } ) ;
400
+ } ) ;
401
+
402
+ it ( 'leaves a gap in the array for undefined of lower index than that of the highest defined value' , function ( ) {
403
+ ori = { } ;
404
+ target = extendDeep ( ori , undef2 ) ;
405
+
406
+ var compare = [ ] ;
407
+ compare [ 0 ] = 1 ;
408
+ // compare[1] left undefined
409
+ compare [ 2 ] = 2 ;
410
+
411
+ expect ( ori ) . toEqual ( {
412
+ layer : { } ,
413
+ arr : compare
414
+ } ) ;
415
+ expect ( undef2 ) . toEqual ( {
416
+ str : undefined ,
417
+ layer : {
418
+ date : undefined
419
+ } ,
420
+ arr : [ 1 , undefined , 2 ]
421
+ } ) ;
422
+ expect ( target ) . toEqual ( {
423
+ layer : { } ,
424
+ arr : compare
391
425
} ) ;
392
426
} ) ;
393
427
You can’t perform that action at this time.
0 commit comments