File tree 1 file changed +35
-0
lines changed
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,16 @@ describe('clone()', () => {
125
125
expect ( a ) . to . equal ( b ) ;
126
126
} ) ;
127
127
128
+ it ( 'clones holey arrays' , ( ) => {
129
+
130
+ const a = new Array ( 3 ) ;
131
+ a [ 1 ] = 'one' ;
132
+
133
+ const b = Hoek . clone ( a ) ;
134
+
135
+ expect ( a ) . to . equal ( b ) ;
136
+ } ) ;
137
+
128
138
it ( 'performs actual copy for shallow keys (no pass by reference)' , ( ) => {
129
139
130
140
const x = Hoek . clone ( nestedObj ) ;
@@ -423,6 +433,31 @@ describe('merge()', () => {
423
433
expect ( a . x [ 0 ] ) . to . not . exist ( ) ;
424
434
} ) ;
425
435
436
+ it ( 'merges from null prototype objects' , ( ) => {
437
+
438
+ const a = { } ;
439
+
440
+ const b = Object . create ( null ) ;
441
+ b . x = true ;
442
+
443
+ Hoek . merge ( a , b ) ;
444
+ expect ( a . x ) . to . be . true ( ) ;
445
+ } ) ;
446
+
447
+ it ( 'skips non-enumerable properties' , ( ) => {
448
+
449
+ const a = { x : 0 } ;
450
+
451
+ const b = { } ;
452
+ Object . defineProperty ( b , 'x' , {
453
+ enumerable : false ,
454
+ value : 1
455
+ } ) ;
456
+
457
+ Hoek . merge ( a , b ) ;
458
+ expect ( a . x ) . to . equal ( 0 ) ;
459
+ } ) ;
460
+
426
461
it ( 'does not throw if source is null' , ( ) => {
427
462
428
463
const a = { } ;
You can’t perform that action at this time.
0 commit comments