forked from zloirock/core-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathes.object.freeze.js
24 lines (23 loc) · 1.07 KB
/
es.object.freeze.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
import { GLOBAL, NATIVE } from '../helpers/constants';
QUnit.test('Object.freeze', assert => {
const { freeze, isFrozen, keys, getOwnPropertyNames, getOwnPropertySymbols } = Object;
const { ownKeys } = GLOBAL.Reflect || {};
assert.isFunction(freeze);
assert.arity(freeze, 1);
assert.name(freeze, 'freeze');
assert.looksNative(freeze);
assert.nonEnumerable(Object, 'freeze');
const data = [42, 'foo', false, null, undefined, {}];
for (const value of data) {
assert.notThrows(() => freeze(value) || true, `accept ${ {}.toString.call(value).slice(8, -1) }`);
assert.same(freeze(value), value, `returns target on ${ {}.toString.call(value).slice(8, -1) }`);
}
if (NATIVE) assert.true(isFrozen(freeze({})));
const results = [];
for (const key in freeze({})) results.push(key);
assert.arrayEqual(results, []);
assert.arrayEqual(keys(freeze({})), []);
assert.arrayEqual(getOwnPropertyNames(freeze({})), []);
if (getOwnPropertySymbols) assert.arrayEqual(getOwnPropertySymbols(freeze({})), []);
if (ownKeys) assert.arrayEqual(ownKeys(freeze({})), []);
});