forked from jonschlinkert/defaults-deep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
40 lines (32 loc) · 1.18 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*!
* defaults-deep <https://github.com/jonschlinkert/defaults-deep>
*
* Copyright (c) 2014-2015 Jon Schlinkert.
* Licensed under the MIT License
*/
'use strict';
/* deps: mocha */
require('should');
var deepDefaults = require('./');
describe('deep-defaults', function () {
it('should copy only missing properties defaults', function () {
deepDefaults({a: 'c'}, {a: 'bbb', d: 'c'}).should.eql({a: 'c', d: 'c'});
});
it('should copy properties from multiple objects', function () {
deepDefaults({a: 'b'}, {c: 'd'}, {e: 'f'}).should.eql({a: 'b', c: 'd', e: 'f'});
});
it('should fill in values that are null', function () {
deepDefaults({a: null}, {a: 'c', d: 'c'}).should.eql({a: 'c', d: 'c'});
});
it('should copy nested values.', function () {
deepDefaults({a: {b: 'c'}}, {a: {d: 'e'}}).should.eql({a: {b: 'c', d: 'e'}});
});
it('should clone when an empty object is passed as the first arg.', function () {
var obj = {};
deepDefaults(obj, {a: {b: 'c'}}, {a: {d: 'e'}});
obj.should.eql({a: {b: 'c', d: 'e'}});
});
it('should return an empty object when the first arg is null.', function () {
deepDefaults(null).should.eql({});
});
});