forked from zloirock/core-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathes.object.define-getter.js
More file actions
23 lines (21 loc) · 944 Bytes
/
Copy pathes.object.define-getter.js
File metadata and controls
23 lines (21 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { DESCRIPTORS, STRICT } from '../helpers/constants';
import __defineGetter__ from 'core-js-pure/es/object/define-getter';
import __defineSetter__ from 'core-js-pure/es/object/define-setter';
if (DESCRIPTORS) {
QUnit.test('Object#__defineGetter__', assert => {
assert.isFunction(__defineGetter__);
const object = {};
assert.same(__defineGetter__(object, 'key', () => 42), undefined, 'void');
assert.same(object.key, 42, 'works');
__defineSetter__(object, 'key', function () {
this.foo = 43;
});
object.key = 44;
assert.same(object.key, 42, 'works with setter #1');
assert.same(object.foo, 43, 'works with setter #2');
if (STRICT) {
assert.throws(() => __defineGetter__(null, 1, () => { /* empty */ }), TypeError, 'Throws on null as `this`');
assert.throws(() => __defineGetter__(undefined, 1, () => { /* empty */ }), TypeError, 'Throws on undefined as `this`');
}
});
}