Skip to content

Commit 73c35e8

Browse files
committedNov 24, 2018
Expand tests for exotic objects
1 parent 927974e commit 73c35e8

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
 

‎test/index.js

+35
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@ describe('clone()', () => {
125125
expect(a).to.equal(b);
126126
});
127127

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+
128138
it('performs actual copy for shallow keys (no pass by reference)', () => {
129139

130140
const x = Hoek.clone(nestedObj);
@@ -423,6 +433,31 @@ describe('merge()', () => {
423433
expect(a.x[0]).to.not.exist();
424434
});
425435

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+
426461
it('does not throw if source is null', () => {
427462

428463
const a = {};

0 commit comments

Comments
 (0)
Please sign in to comment.