-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbroken-symlink.spec.js
More file actions
66 lines (56 loc) · 1.52 KB
/
broken-symlink.spec.js
File metadata and controls
66 lines (56 loc) · 1.52 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const fs = require('fs');
const glob = require('../');
const mkdirp = require('mkdirp');
const rimraf = require('rimraf');
function skipIfWindows() {
if (process.platform === 'win32') {
pending('Symlinks not supported on Windows');
}
}
function cleanup () {
rimraf.sync('broken-symlink');
}
describe('broken-symlink', () => {
beforeEach(() => {
process.chdir(__dirname);
mkdirp.sync(process.cwd()+'/broken-symlink/a/broken-link');
fs.symlinkSync('this-does-not-exist', 'broken-symlink/a/broken-link/link');
});
afterEach(() => {
process.chdir(__dirname);
cleanup();
});
const link = 'broken-symlink/a/broken-link/link';
const patterns = [
'broken-symlink/a/broken-link/*',
'broken-symlink/a/broken-link/**',
'broken-symlink/a/broken-link/**/link',
'broken-symlink/a/broken-link/**/*',
'broken-symlink/a/broken-link/link',
'broken-symlink/a/broken-link/{link,asdf}',
'broken-symlink/a/broken-link/+(link|asdf)',
'broken-symlink/a/broken-link/!(asdf)'
];
const opts = [
null,
{ nonull: true },
{ mark: true },
{ stat: true },
{ follow: true }
];
patterns.forEach((pattern) => {
opts.forEach((opt) => {
it('async test pattern='+pattern+', opts='+JSON.stringify(opt), done => {
skipIfWindows();
glob('.', {...opt, pattern}, (er, res) => {
if (er) {
fail(er);
return done();
}
expect(res.indexOf(link)).not.toBe(-1);
done();
});
})
});
});
});