Sha256: 1b57711db133e6416c54852862c4886c22b092c2171b07c4a1d1491ee530286d

Contents?: true

Size: 1.85 KB

Versions: 46

Compression:

Stored size: 1.85 KB

Contents

"use strict";

module.exports = function (t, a) {
	var o, o1, o2, x, y = {}, z = {};
	o = { inherited: true };
	o1 = Object.create(o);
	o1.visible = z;
	o1.nonremovable = "raz";
	Object.defineProperty(o1, "hidden", { value: "hidden" });

	o2 = Object.defineProperties({}, { nonremovable: { value: y } });
	o2.other = "other";

	try {
 t(o2, o1);
} catch (ignore) {}

	a(o2.visible, z, "Enumerable");
	a(o1.hidden, "hidden", "Not Enumerable");
	a(o2.propertyIsEnumerable("visible"), true, "Enumerable is enumerable");
	a(o2.propertyIsEnumerable("hidden"), false,
		"Not enumerable is not enumerable");

	a(o2.hasOwnProperty("inherited"), false, "Extend only own");
	a(o2.inherited, undefined, "Extend ony own: value");

	a(o2.nonremovable, y, "Do not overwrite non configurable");
	a(o2.other, "other", "Own kept");

	x = {};
	t(x, o2);
	try {
 t(x, o1);
} catch (ignore) {}

	a(x.visible, z, "Enumerable");
	a(x.hidden, "hidden", "Not Enumerable");
	a(x.propertyIsEnumerable("visible"), true, "Enumerable is enumerable");
	a(x.propertyIsEnumerable("hidden"), false,
		"Not enumerable is not enumerable");

	a(x.hasOwnProperty("inherited"), false, "Extend only own");
	a(x.inherited, undefined, "Extend ony own: value");

	a(x.nonremovable, y, "Ignored non configurable");
	a(x.other, "other", "Other");

	x.visible = 3;
	a(x.visible, 3, "Writable is writable");

	x = {};
	t(x, o1);
	a.throws(function () {
		x.hidden = 3;
	}, "Not writable is not writable");

	x = {};
	t(x, o1);
	delete x.visible;
	a.ok(!x.hasOwnProperty("visible"), "Configurable is configurable");

	x = {};
	t(x, o1);
	a.throws(function () {
		delete x.hidden;
	}, "Not configurable is not configurable");

	x = Object.defineProperty({}, "foo",
		{ configurable: false, writable: true, enumerable: false, value: "bar" });

	try {
 t(x, { foo: "lorem" });
} catch (ignore) {}
	a(x.foo, "bar", "Writable, not enumerable");
};

Version data entries

46 entries across 46 versions & 3 rubygems

Version Path
govuk_publishing_components-18.0.0 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.21.0 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.20.0 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.19.1 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.19.0 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.18.0 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.17.0 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.16.0 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.15.0 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.14.0 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.13.0 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.12.2 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.12.1 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.12.0 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.11.0 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.10.0 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.9.0 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.8.0 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.7.0 node_modules/es5-ext/test/object/mixin.js
govuk_publishing_components-17.6.1 node_modules/es5-ext/test/object/mixin.js