-
-
Notifications
You must be signed in to change notification settings - Fork 151
/
import-meta.js
45 lines (38 loc) 路 918 Bytes
/
import-meta.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
41
42
43
44
45
import test from 'ava';
import meow from '../../source/index.js';
const verifyImportMeta = test.macro((t, {cli, error}) => {
if (error) {
t.throws(cli, {message: 'The `importMeta` option is required. Its value must be `import.meta`.'});
} else {
t.notThrows(cli);
}
});
test('main', verifyImportMeta, {
cli: () => meow({
importMeta: import.meta,
}),
});
test('with help shortcut', verifyImportMeta, {
cli: () => meow(`
unicorns
rainbows
`, {
importMeta: import.meta,
}),
});
test('invalid package url', verifyImportMeta, {
cli: () => meow({importMeta: '/path/to/package'}),
error: true,
});
test('throws if unset', verifyImportMeta, {
cli: () => meow('foo', {}),
error: true,
});
test('throws if unset - options only', verifyImportMeta, {
cli: () => meow({}),
error: true,
});
test('throws if unset - help shortcut only', verifyImportMeta, {
cli: () => meow('foo'),
error: true,
});