Sha256: c95cd5e3e7ea2a0acf35ccdcecb72be8d8e22edf5f32259e9df58c9330ed4c44

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

var assert = require('assert');
var util = require('../index');

describe('extend', function() {
  it('Two arguments', function() {
    var target = { k: 'v' };
    var source = { k: 'v2' };

    util.extend(target, source);

    assert.deepEqual(target, { k: 'v2' });
  });

  it('More arguments', function() {
    var target = { k: 'v' };
    var source = { k: 'v2' };
    var source2 = { k: 'v3' };

    util.extend(target, source, source2);

    assert.deepEqual(target, { k: 'v3' });
  });

  it('deep clone', function() {
    var target = {};
    var target2 = {
      k1: { age: 5 },
      k3: [{ age: 5 }]
    };
    var source = {
      k1: { k: 'v' },
      k2: [1, 2, 3 ],
      k3: [
        { k: 'v' },
        { k2: 'v2' },
        { k3: 'v3' }
      ]
    };

    util.extend(target, source);
    util.extend(target2, source);
    
    assert.deepEqual(target, source);
    assert.deepEqual(target2, {
      k1: { k: 'v', age: 5 },
      k2: [1, 2, 3],
      k3: [
        { k: 'v', age: 5},
        { k2: 'v2' },
        { k3: 'v3' }
      ]
    });
  });
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
learn_create-0.0.22 lib/templates/javascript_lab_template/node_modules/utils-extend/test/extend.js