forked from zloirock/core-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathes.object.get-own-property-descriptor.js
27 lines (25 loc) · 1.14 KB
/
es.object.get-own-property-descriptor.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
import { DESCRIPTORS } from '../helpers/constants';
QUnit.test('Object.getOwnPropertyDescriptor', assert => {
const { getOwnPropertyDescriptor } = Object;
assert.isFunction(getOwnPropertyDescriptor);
assert.arity(getOwnPropertyDescriptor, 2);
assert.name(getOwnPropertyDescriptor, 'getOwnPropertyDescriptor');
assert.looksNative(getOwnPropertyDescriptor);
assert.nonEnumerable(Object, 'getOwnPropertyDescriptor');
assert.deepEqual(getOwnPropertyDescriptor({ q: 42 }, 'q'), {
writable: true,
enumerable: true,
configurable: true,
value: 42,
});
assert.same(getOwnPropertyDescriptor({}, 'toString'), undefined);
const primitives = [42, 'foo', false];
for (const value of primitives) {
assert.notThrows(() => getOwnPropertyDescriptor(value) || true, `accept ${ typeof value }`);
}
assert.throws(() => getOwnPropertyDescriptor(null), TypeError, 'throws on null');
assert.throws(() => getOwnPropertyDescriptor(undefined), TypeError, 'throws on undefined');
});
QUnit.test('Object.getOwnPropertyDescriptor.sham flag', assert => {
assert.same(Object.getOwnPropertyDescriptor.sham, DESCRIPTORS ? undefined : true);
});