Sha256: a97ac255e238e12818fb9ca9db5aeb232a480940f864721f1acb3cf1e99db40a

Contents?: true

Size: 1.6 KB

Versions: 5

Compression:

Stored size: 1.6 KB

Contents

var I18n = require("../../app/assets/javascripts/i18n")
  , Translations = require("./translations")
;

describe("Extend", function () {
  it("should return an object", function () {
    expect(typeof I18n.extend()).toBe('object');
  });

  it("should merge 2 objects into 1", function () {
    var obj1 = {
      test1: "abc"
    }
    , obj2 = {
      test2: "xyz"
    }
    , expected = {
      test1: "abc"
      , test2: "xyz"
    };

    expect(I18n.extend(obj1,obj2)).toEqual(expected);
  });
  it("should overwrite a property from obj1 with the same property of obj2", function () {
    var obj1 = {
      test1: "abc"
      , test3: "def"
    }
    , obj2 = {
      test2: "xyz"
      , test3: "uvw"
    }
    , expected = {
      test1: "abc"
      , test2: "xyz"
      , test3: "uvw"
    };

    expect(I18n.extend(obj1,obj2)).toEqual(expected);
  });

  it("should merge deeply from obj1 with the same key of obj2", function() {
    var obj1 = {
      test1: {
        test2: "abc"
      }
    }
    , obj2 = {
      test1: {
        test3: "xyz"
      }
    }
    , expected = {
      test1: {
        test2: "abc"
        , test3: "xyz"
      }
    }

    expect(I18n.extend(obj1, obj2)).toEqual(expected);
  });

  it("should correctly merge string, numberic and boolean values", function() {
    var obj1 = {
      test1: {
        test2: false
      }
    }
    , obj2 = {
      test1: {
        test3: 23,
        test4: 'abc'
      }
    }
    , expected = {
      test1: {
        test2: false
        , test3: 23
        , test4: 'abc'
      }
    }

    expect(I18n.extend(obj1, obj2)).toEqual(expected);
  });
});

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
i18n-js-3.0.2 spec/js/extend.spec.js
i18n-js-3.0.1 spec/js/extend.spec.js
i18n-js-3.0.0 spec/js/extend.spec.js
i18n-js-3.0.0.rc16 spec/js/extend.spec.js
i18n-js-3.0.0.rc15 spec/js/extend.spec.js