forked from zloirock/core-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathes.object.define-property.js
31 lines (26 loc) · 1.01 KB
/
es.object.define-property.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { DESCRIPTORS } from '../helpers/constants';
import create from 'core-js-pure/es/object/create';
import defineProperty from 'core-js-pure/es/object/define-property';
QUnit.test('Object.defineProperty', assert => {
assert.isFunction(defineProperty);
assert.arity(defineProperty, 3);
const source = {};
const result = defineProperty(source, 'q', {
value: 42,
});
assert.same(result, source);
assert.same(result.q, 42);
if (DESCRIPTORS) {
// eslint-disable-next-line prefer-arrow-callback -- required for testing
assert.same(defineProperty(function () { /* empty */ }, 'prototype', {
value: 42,
writable: false,
}).prototype, 42, 'function prototype with non-writable descriptor');
}
assert.throws(() => defineProperty(42, 1, {}));
assert.throws(() => defineProperty({}, create(null), {}));
assert.throws(() => defineProperty({}, 1, 1));
});
QUnit.test('Object.defineProperty.sham flag', assert => {
assert.same(defineProperty.sham, DESCRIPTORS ? undefined : true);
});