forked from achingbrain/it
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
76 lines (56 loc) · 1.88 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
69
70
71
72
73
74
75
76
const test = require('ava')
const all = require('it-all')
const glob = require('.')
const path = require('path')
test('it should match file', async t => {
const files = await all(glob('.', '**/*'))
t.truthy(files.includes('README.md'))
})
test('it should match file in subdirectory', async t => {
const files = await all(glob('.', '**/*'))
t.truthy(files.includes(path.join('node_modules', 'it-all')))
})
test('it should match one', async t => {
const files = await all(glob('.', 'README.md'))
t.deepEqual(files, ['README.md'])
})
test('it should match files', async t => {
const files = await all(glob('README.md', 'README.md'))
t.deepEqual(files, ['README.md'])
})
test('it should ignore files', async t => {
const files = await all(glob('.', '**/*!(*/index.js|**/node_modules/**)'))
t.falsy(files.includes('test/index.js'))
})
test('it should ignore files from absolute directory', async t => {
const files = await all(glob(__dirname, '**/*!(test/index.js|)**/node_modules/**'))
t.falsy(files.includes(path.resolve(__dirname, 'index.js')))
})
test('it returns absolute paths', async t => {
const files = await all(glob(__dirname, '**/*', {
absolute: true
}))
files.forEach(file => {
t.truthy(path.isAbsolute(file))
})
})
test('it returns relative paths', async t => {
const files = await all(glob(__dirname, '**/*', {
absolute: false
}))
files.forEach(file => {
t.falsy(path.isAbsolute(file))
})
})
test('it matches directories', async t => {
const files = await all(glob(__dirname, 'node_modules/*'))
t.truthy(files.includes(path.join('node_modules', 'it-all')))
})
test('it skips directories', async t => {
const files = await all(glob(__dirname, 'node_modules/**/*', {
nodir: true,
dot: true
}))
t.falsy(files.includes(path.join('node_modules', '.bin')))
t.truthy(files.includes(path.join('node_modules', '.bin', 'ava')))
})