/
test.js
73 lines (64 loc) · 1.65 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
var tape = require('tape')
var path = require('path')
var ignore = require('./')
tape('node_modules', function(t) {
var filter = ignore.sync(path.join(__dirname, '.gitignore'))
t.ok(filter('node_modules'))
t.notOk(filter('meh'))
t.end()
})
tape('index.js', function(t) {
var filter = ignore.sync(path.join(__dirname, '.gitignore'))
t.notOk(filter('index.js'))
t.end()
})
tape('default value', function(t) {
var filter = ignore.sync(path.join(__dirname, 'non-existing')) || ignore.compile('node_modules')
t.ok(filter('node_modules'))
t.notOk(filter('meh'))
t.end()
})
tape('compile multiple lines', function(t) {
var filter = ignore.compile('a\nb\nc')
t.ok(filter('a'))
t.ok(filter('b'))
t.notOk(filter('d'))
t.end()
})
tape('compile multiple lines with \\r', function(t) {
var filter = ignore.compile('a\r\nb\nc\r\nd');
t.ok(filter('a'))
t.ok(filter('b'))
t.ok(filter('c'))
t.ok(filter('d'))
t.notOk(filter('e'))
t.end()
})
tape('gitignore glob style', function(t) {
var filter = ignore.compile('test')
t.ok(filter('test'))
t.ok(filter('foo/test'))
t.ok(filter('test/foo'))
t.ok(filter('bar/test/foo'))
t.end()
})
tape('gitignore inverse style', function(t) {
var filter = ignore.compile('test\n!foo/test')
t.ok(filter('test'))
t.notOk(filter('foo/test'))
t.ok(filter('test/foo'))
t.ok(filter('bar/test/foo'))
t.end()
})
tape('gitignore anchored', function(t) {
var filter = ignore.compile('/test')
t.ok(filter('test'))
t.notOk(filter('foo/test'))
t.end()
})
tape('comments', function(t) {
var filter = ignore.compile('#test')
t.notOk(filter('test'))
t.notOk(filter('foo/test'))
t.end()
})