it('modifies the object in-place', function () { var arr = [1, 2, 3, 4, 5]; proclaim.deepStrictEqual(arr.copyWithin(0, 3), [4, 5, 3, 4, 5]); proclaim.deepStrictEqual(arr, [4, 5, 3, 4, 5]); });
it('works with arraylike objects', function () { var args = (function () { return arguments; }(1, 2, 3)); var argsClass = Object.prototype.toString.call(args); proclaim.deepStrictEqual(Array.prototype.slice.call(args), [1, 2, 3]); Array.prototype.copyWithin.call(args, -2, 0); proclaim.deepStrictEqual(Array.prototype.slice.call(args), [1, 1, 2]); proclaim.strictEqual(Object.prototype.toString.call(args), argsClass); });
it('should check inherited properties as well', function () { var Parent = function Parent() {}; Parent.prototype[0] = 'foo'; var sparse = new Parent(); sparse[1] = 1; sparse[2] = 2; sparse.length = 3; var result = Array.prototype.copyWithin.call(sparse, 1, 0); proclaim.ok(result['0']); proclaim.notOk(Object.prototype.hasOwnProperty.call(result, '0')); proclaim.isTrue(Object.prototype.hasOwnProperty.call(result, '1')); proclaim.deepEqual(result[0], 'foo'); proclaim.deepEqual(result[1], 'foo'); proclaim.deepEqual(result[2], 1); proclaim.deepEqual(result.length, 3 ); });
it('throws if called with null context', function () { proclaim["throws"](function () { return Array.prototype.copyWithin.call(null, 0); }, TypeError); });
/* globals proclaim */ it('is a function', function () { proclaim.isFunction(Array.prototype.copyWithin); });
it('has correct arity', function () { proclaim.arity(Array.prototype.copyWithin, 2); });
it('has correct name', function () { proclaim.hasName(Array.prototype.copyWithin, 'copyWithin'); });
it('throws if called with undefined context', function () { proclaim["throws"](function () { return Array.prototype.copyWithin.call(undefined, 0); }, TypeError); });