forked from sindresorhus/globals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
40 lines (35 loc) · 1.09 KB
/
test.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import test from 'ava';
import globals from '.';
test('main', t => {
t.is(typeof globals, 'object');
t.true(Object.keys(globals).length > 10 && Object.keys(globals).length < 1000);
});
test('ensure alphabetical order', t => {
for (const env of Object.keys(globals)) {
const keys = Object.keys(globals[env]);
t.deepEqual(
keys.slice(), keys.sort((a, b) => a.localeCompare(b)),
`The \`${env}\` keys don't have the correct alphabetical order`
);
}
});
test('`node` is `nodeBuiltin` with CommonJS arguments', t => {
// `globals.node` has `global`` which isn't a CommonJS argument and doesn't include
// `__filename` and `__dirname` which are.
const commonjsArgs = {
__dirname: false,
__filename: false,
exports: true,
module: false,
require: false
};
t.deepEqual({...globals.nodeBuiltin, ...commonjsArgs}, globals.node);
// Ensure that there's no overlap between true globals and the CommonJS arguments above.
for (const builtin of Object.keys(globals.nodeBuiltin)) {
t.is(
commonjsArgs[builtin],
undefined,
`The builtin ${builtin} is not a CommonJS argument`
);
}
});