File: index.test.js

package info (click to toggle)
node-utils-merge 1.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 140 kB
  • sloc: makefile: 16
file content (54 lines) | stat: -rw-r--r-- 1,373 bytes parent folder | download
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var merge = require('../index');
var chai = require('chai');

global.expect = chai.expect;

describe('merge', function() {
  
  it('an object', function() {
    var a = { foo: 'bar' }
      , b = { bar: 'baz' };
    var o = merge(a, b);
    
    it('should merge properties into first object', function() {
      expect(Object.keys(a)).to.have.length(2);
      expect(a.foo).to.be.equal('bar');
      expect(a.bar).to.be.equal('baz');
    });
    
    it('should return first argument', function() {
      expect(o).to.be.equal(a);
    });
  });
  
  it('an object with duplicate key', function() {
    var a = { foo: 'bar', qux: 'corge' }
      , b = { foo: 'baz' };
    var o = merge(a, b);
    
    it('should merge properties into first object', function() {
      expect(Object.keys(a)).to.have.length(2);
      expect(a.foo).to.be.equal('baz');
      expect(a.qux).to.be.equal('corge');
    });
    
    it('should return first argument', function() {
      expect(o).to.be.equal(a);
    });
  });
  
  it('without a source object', function() {
    var a = { foo: 'bar' };
    var o = merge(a);
    
    it('should leave first object unmodified', function() {
      expect(Object.keys(a)).to.have.length(1);
      expect(a.foo).to.be.equal('bar');
    });
    
    it('should return first argument', function() {
      expect(o).to.be.equal(a);
    });
  });
  
});