UNPKG

@csegames/camelot-unchained

Version:

Camelot Unchained Client Library

33 lines (32 loc) 1.38 kB
"use strict"; /* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ Object.defineProperty(exports, "__esModule", { value: true }); var objectUtils = require("./objectUtils"); describe('objectUtils', function () { describe('clone', function () { test('should return an object', function () { var original = { foo: 'bar', bar: { baz: 'foo' } }; var cloned = objectUtils.clone(original); expect(cloned).toBeInstanceOf(Object); }); it('contains exact values of input object', function () { var original = { foo: 'bar', bar: { baz: 'foo' } }; var cloned = objectUtils.clone(original); expect(cloned).toEqual(original); }); it('should not reference input object', function () { var original = { foo: 'bar', bar: { baz: 'foo' } }; var originalReference = original; var cloned = objectUtils.clone(original); expect(originalReference).toBe(original); expect(cloned).not.toBe(original); expect(cloned.foo).toEqual(original.foo); cloned.foo = 'baz'; expect(cloned.foo).not.toEqual(original.foo); }); }); });