forked from zloirock/core-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
es.object.lookup-getter.js
21 lines (19 loc) · 1.02 KB
/
es.object.lookup-getter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { DESCRIPTORS, STRICT } from '../helpers/constants';
import { __lookupGetter__, __defineGetter__, create } from 'core-js-pure/features/object';
if (DESCRIPTORS) {
QUnit.test('Object#__lookupGetter__', assert => {
assert.isFunction(__lookupGetter__);
assert.same(__lookupGetter__({}, 'key'), undefined, 'empty object');
assert.same(__lookupGetter__({ key: 42 }, 'key'), undefined, 'data descriptor');
const object = {};
function getter() { /* empty */ }
__defineGetter__(object, 'key', getter);
assert.same(__lookupGetter__(object, 'key'), getter, 'own getter');
assert.same(__lookupGetter__(create(object), 'key'), getter, 'proto getter');
assert.same(__lookupGetter__(create(object), 'foo'), undefined, 'empty proto');
if (STRICT) {
assert.throws(() => __lookupGetter__(null, 1, () => { /* empty */ }), TypeError, 'Throws on null as `this`');
assert.throws(() => __lookupGetter__(undefined, 1, () => { /* empty */ }), TypeError, 'Throws on undefined as `this`');
}
});
}