-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
54 lines (44 loc) · 1.46 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'use strict';
const main = require('.');
const test = require('tape');
test('assertValidGlobOpts()', t => {
t.doesNotThrow(
() => main(),
'should throw no errors when it takes no arguments.'
);
t.throws(
() => main({}, [], null),
/^TypeError.*Expected 0, 1 or 2 arguments \(\[<object>, <array>\]\), but got 3\./u,
'should throw no errors when it takes too many arguments.'
);
t.doesNotThrow(
() => main({nodir: true}),
'should throw no errors when it takes a valid glob option.'
);
t.throws(
() => main({cwd: 1}),
/^TypeError.*node-glob expected `cwd` option to be a directory path \(string\), but got 1 \(number\)\./u,
'should throw an error when it takes an invalid glob option.'
);
t.throws(
() => main({cache: {'1': 2}, realPath: true}),
/^Error: 2 errors found in the glob options:\n.* {2}1\. .*\n {2}2\. .*/u,
'should throw an error with multiple lines when the object inludes multiple invalid values.'
);
t.throws(
() => main({follow: new Map([[true, false]]), noext: Infinity}),
/^TypeError/u,
'should throw a type error when every error in the result is type error.'
);
t.throws(
() => main({x: '!!!err!!!'}, [({x}) => new Error(x)]),
/^Error.*!!!err!!!/u,
'should support custom validation parameter.'
);
t.throws(
() => main({}, new Uint32Array()),
/^TypeError.*Expected an array of functions, but got a non-array value Uint32Array \[ {2}\]\./u,
'should invalidate the non-array second aergument.'
);
t.end();
});