-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
69 lines (60 loc) · 2.37 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
'use strict';
require('mocha');
var assert = require('assert');
var hasGlob = require('./');
describe('hasGlob', function () {
it('should return `true` if the array has a glob pattern:', function () {
assert(hasGlob(['foo', 'bar', '*.js']));
assert(hasGlob(['foo', 'bar', '!*.js']));
assert(hasGlob(['foo', 'bar', '!foo']));
assert(hasGlob(['foo', 'bar', '!foo.js']));
assert(hasGlob(['foo', 'bar', '**/abc.js']));
assert(hasGlob(['foo', 'bar', 'abc/*.js']));
});
it('should work with strings:', function () {
assert(hasGlob('*.js'));
assert(hasGlob('!*.js'));
assert(hasGlob('!foo'));
assert(hasGlob('!foo.js'));
assert(hasGlob('**/abc.js'));
assert(hasGlob('abc/*.js'));
});
it('should return `true` if a path has brace characters:', function () {
assert(hasGlob(['foo', 'bar', 'abc/{a,b}.js']));
assert(hasGlob(['foo', 'bar', 'abc/{a..z}.js']));
assert(hasGlob(['foo', 'bar', 'abc/{a..z..2}.js']));
});
it('should return `true` if it has an extglob:', function () {
assert(hasGlob(['foo', 'bar', 'abc/@(a).js']));
assert(hasGlob(['foo', 'bar', 'abc/!(a).js']));
assert(hasGlob(['foo', 'bar', 'abc/+(a).js']));
assert(hasGlob(['foo', 'bar', 'abc/*(a).js']));
assert(hasGlob(['foo', 'bar', 'abc/?(a).js']));
assert(hasGlob(['foo', 'bar', 'abc/@(.js)']));
assert(hasGlob(['foo', 'bar', 'abc/!(.js)']));
assert(hasGlob(['foo', 'bar', 'abc/+(.js)']));
assert(hasGlob(['foo', 'bar', 'abc/*(.js)']));
assert(hasGlob(['foo', 'bar', 'abc/?(.js)']));
});
it('should return `true` if a path has regex characters:', function () {
assert(hasGlob(['foo', 'bar', 'abc/(aaa|bbb).js']));
assert(hasGlob(['foo', 'bar', 'abc/?.js']));
assert(hasGlob(['foo', 'bar', '?.js']));
assert(hasGlob(['foo', 'bar', '[abc].js']));
assert(hasGlob(['foo', 'bar', '[^abc].js']));
assert(hasGlob(['foo', 'bar', 'a/b/c/[a-z].js']));
assert(hasGlob(['foo', 'bar', '[a-j]*[^c]b/c']));
});
it('should return `false` if it is not a string:', function () {
assert(!hasGlob([]));
assert(!hasGlob([null]));
assert(!hasGlob([undefined]));
assert(!hasGlob([{}]));
});
it('should return `false` if it is not a glob pattern:', function () {
assert(!hasGlob(['.']));
assert(!hasGlob(['aa']));
assert(!hasGlob(['abc.js']));
assert(!hasGlob(['abc/def/ghi.js']));
});
});