forked from zloirock/core-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathes.object.keys.js
More file actions
25 lines (23 loc) · 805 Bytes
/
Copy pathes.object.keys.js
File metadata and controls
25 lines (23 loc) · 805 Bytes
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
import { includes } from '../helpers/helpers';
import keys from 'core-js-pure/es/object/keys';
QUnit.test('Object.keys', assert => {
assert.isFunction(keys);
assert.arity(keys, 1);
function F1() {
this.w = 1;
}
function F2() {
this.toString = 1;
}
F1.prototype.q = F2.prototype.q = 1;
assert.deepEqual(keys([1, 2, 3]), ['0', '1', '2']);
assert.deepEqual(keys(new F1()), ['w']);
assert.deepEqual(keys(new F2()), ['toString']);
assert.false(includes(keys(Array.prototype), 'push'));
const primitives = [42, 'foo', false];
for (const value of primitives) {
assert.notThrows(() => keys(value), `accept ${ typeof value }`);
}
assert.throws(() => keys(null), TypeError, 'throws on null');
assert.throws(() => keys(undefined), TypeError, 'throws on undefined');
});