-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbash-comparison.spec.js
More file actions
45 lines (39 loc) · 1.14 KB
/
bash-comparison.spec.js
File metadata and controls
45 lines (39 loc) · 1.14 KB
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
// basic test
// show that it does the same thing by default as the shell.
const glob = require('../');
const path = require('path');
function alphasort (a, b) {
a = a.toLowerCase();
b = b.toLowerCase();
return a > b ? 1 : a < b ? -1 : 0;
}
function cleanResults (m) {
// normalize discrepancies in ordering, duplication,
// and ending slashes.
return m.sort(alphasort);
}
describe('bash-comparison', () => {
beforeEach(() => {
process.chdir(__dirname+'/fixtures');
});
['a/{b,c,d,e,f}/**/g'].forEach((pattern) => {
let expectedFiles = [];
// anything regarding the symlink thing will fail on windows, so just skip it
if (process.platform === 'win32') {
expectedFiles = expectedFiles.filter(m => m.indexOf('symlink')===-1);
}
it(pattern, (done) => {
const g = glob('.', {pattern});
let matches = [];
g.on('match', (match) => {
matches.push(match.relative);
})
g.on('end', () => {
// sort and unmark, just to match the shell results
matches = cleanResults(matches);
expect(matches).toEqual(expectedFiles);
done();
});
});
});
});