BigW Consortium Gitlab

object_spec.js.es6 603 Bytes
Newer Older
1
require('~/extensions/object');
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

describe('Object extensions', () => {
  describe('assign', () => {
    it('merges source object into target object', () => {
      const targetObj = {};
      const sourceObj = {
        foo: 'bar',
      };
      Object.assign(targetObj, sourceObj);
      expect(targetObj.foo).toBe('bar');
    });

    it('merges object with the same properties', () => {
      const targetObj = {
        foo: 'bar',
      };
      const sourceObj = {
        foo: 'baz',
      };
      Object.assign(targetObj, sourceObj);
      expect(targetObj.foo).toBe('baz');
    });
  });
});