Sha256: 00b7ccd4fb74b70387244e1c0774cb75192cdaea8fba3a6809c7cf2c28885155

Contents?: true

Size: 1.37 KB

Versions: 61

Compression:

Stored size: 1.37 KB

Contents

'use strict';

var test = require('tape');

var hasPropertyDescriptors = require('../');

var sentinel = {};

test('hasPropertyDescriptors', function (t) {
	t.equal(typeof hasPropertyDescriptors, 'function', 'is a function');
	t.equal(typeof hasPropertyDescriptors.hasArrayLengthDefineBug, 'function', '`hasArrayLengthDefineBug` property is a function');

	var yes = hasPropertyDescriptors();
	t.test('property descriptors', { skip: !yes }, function (st) {
		var o = { a: sentinel };

		st.deepEqual(
			Object.getOwnPropertyDescriptor(o, 'a'),
			{
				configurable: true,
				enumerable: true,
				value: sentinel,
				writable: true
			},
			'has expected property descriptor'
		);

		Object.defineProperty(o, 'a', { enumerable: false, writable: false });

		st.deepEqual(
			Object.getOwnPropertyDescriptor(o, 'a'),
			{
				configurable: true,
				enumerable: false,
				value: sentinel,
				writable: false
			},
			'has expected property descriptor after [[Define]]'
		);

		st.end();
	});

	var arrayBug = hasPropertyDescriptors.hasArrayLengthDefineBug();
	t.test('defining array lengths', { skip: !yes || arrayBug }, function (st) {
		var arr = [1, , 3]; // eslint-disable-line no-sparse-arrays
		st.equal(arr.length, 3, 'array starts with length 3');

		Object.defineProperty(arr, 'length', { value: 5 });

		st.equal(arr.length, 5, 'array ends with length 5');

		st.end();
	});

	t.end();
});

Version data entries

61 entries across 61 versions & 3 rubygems

Version Path
immosquare-cleaner-0.1.68 node_modules/has-property-descriptors/test/index.js
immosquare-cleaner-0.1.67 node_modules/has-property-descriptors/test/index.js
immosquare-cleaner-0.1.66 node_modules/has-property-descriptors/test/index.js
immosquare-cleaner-0.1.65 node_modules/has-property-descriptors/test/index.js
immosquare-cleaner-0.1.64 node_modules/has-property-descriptors/test/index.js
immosquare-cleaner-0.1.63 node_modules/has-property-descriptors/test/index.js
rapid_stack-0.2.0 templates/frontend/node_modules/has-property-descriptors/test/index.js
rapid_stack-0.1.1 templates/FrontEnd/node_modules/has-property-descriptors/test/index.js
rapid_stack-0.1.0 templates/FrontEnd/node_modules/has-property-descriptors/test/index.js
immosquare-cleaner-0.1.62 node_modules/has-property-descriptors/test/index.js
immosquare-cleaner-0.1.61 node_modules/has-property-descriptors/test/index.js
immosquare-cleaner-0.1.60 node_modules/has-property-descriptors/test/index.js
immosquare-cleaner-0.1.59 node_modules/has-property-descriptors/test/index.js
immosquare-cleaner-0.1.58 node_modules/has-property-descriptors/test/index.js
immosquare-cleaner-0.1.57 node_modules/has-property-descriptors/test/index.js
immosquare-cleaner-0.1.56 node_modules/has-property-descriptors/test/index.js
immosquare-cleaner-0.1.55 node_modules/has-property-descriptors/test/index.js
immosquare-cleaner-0.1.54 node_modules/has-property-descriptors/test/index.js
immosquare-cleaner-0.1.53 node_modules/has-property-descriptors/test/index.js
immosquare-cleaner-0.1.52 node_modules/has-property-descriptors/test/index.js