mirror of
https://github.com/hanzoai/core-js.git
synced 2026-10-30 14:46:13 +00:00
20 lines
808 B
JavaScript
20 lines
808 B
JavaScript
import { DESCRIPTORS } from '../helpers/constants.js';
|
|
|
|
import getOwnPropertyDescriptor from 'core-js-pure/es/reflect/get-own-property-descriptor';
|
|
|
|
QUnit.test('Reflect.getOwnPropertyDescriptor', assert => {
|
|
assert.isFunction(getOwnPropertyDescriptor);
|
|
assert.arity(getOwnPropertyDescriptor, 2);
|
|
if ('name' in getOwnPropertyDescriptor) {
|
|
assert.name(getOwnPropertyDescriptor, 'getOwnPropertyDescriptor');
|
|
}
|
|
const object = { baz: 789 };
|
|
const descriptor = getOwnPropertyDescriptor(object, 'baz');
|
|
assert.same(descriptor.value, 789);
|
|
assert.throws(() => getOwnPropertyDescriptor(42, 'constructor'), TypeError, 'throws on primitive');
|
|
});
|
|
|
|
QUnit.test('Reflect.getOwnPropertyDescriptor.sham flag', assert => {
|
|
assert.same(getOwnPropertyDescriptor.sham, DESCRIPTORS ? undefined : true);
|
|
});
|