@@ -33,17 +33,17 @@ describe('statusMatrix', () => {
33
33
await fs.write(path.join(dir, 'a.txt'), 'Hi')
34
34
await add({ dir, gitdir, filepath: 'a.txt' })
35
35
await fs.write(path.join(dir, 'a.txt'), acontent)
36
-
matrix = await statusMatrix({ dir, gitdir, pattern: 'a.txt' })
36
+
matrix = await statusMatrix({ dir, gitdir, filepaths: ['a.txt'] })
37
37
expect(matrix).toEqual([['a.txt', 1, 1, 3]])
38
38
39
39
await remove({ dir, gitdir, filepath: 'a.txt' })
40
-
matrix = await statusMatrix({ dir, gitdir, pattern: 'a.txt' })
40
+
matrix = await statusMatrix({ dir, gitdir, filepaths: ['a.txt'] })
41
41
expect(matrix).toEqual([['a.txt', 1, 1, 0]])
42
42
43
43
await fs.write(path.join(dir, 'e.txt'), 'Hi')
44
44
await add({ dir, gitdir, filepath: 'e.txt' })
45
45
await fs.rm(path.join(dir, 'e.txt'))
46
-
matrix = await statusMatrix({ dir, gitdir, pattern: 'e.txt' })
46
+
matrix = await statusMatrix({ dir, gitdir, filepaths: ['e.txt'] })
47
47
expect(matrix).toEqual([['e.txt', 0, 0, 3]])
48
48
})
49
49
@@ -54,13 +54,13 @@ describe('statusMatrix', () => {
54
54
await fs.write(path.join(dir, 'b.txt'), 'Hi')
55
55
await add({ dir, gitdir, filepath: 'b.txt' })
56
56
// Test
57
-
const a = await statusMatrix({ dir, gitdir, pattern: 'a.txt' })
57
+
const a = await statusMatrix({ dir, gitdir, filepaths: ['a.txt'] })
58
58
expect(a).toEqual([['a.txt', 0, 2, 0]])
59
-
const b = await statusMatrix({ dir, gitdir, pattern: 'b.txt' })
59
+
const b = await statusMatrix({ dir, gitdir, filepaths: ['b.txt'] })
60
60
expect(b).toEqual([['b.txt', 0, 2, 2]])
61
61
})
62
62
63
-
it('statusMatrix (pattern vs filepaths)', async () => {
63
+
it('statusMatrix with filepaths', async () => {
64
64
// Setup
65
65
const { dir, gitdir } = await makeFixture('test-statusMatrix-filepath')
66
66
// Test
@@ -76,9 +76,6 @@ describe('statusMatrix', () => {
76
76
['i/i.txt', 0, 2, 0]
77
77
])
78
78
79
-
matrix = await statusMatrix({ dir, gitdir, pattern: 'i' })
80
-
expect(matrix).toEqual([])
81
-
82
79
matrix = await statusMatrix({ dir, gitdir, filepaths: ['i'] })
83
80
expect(matrix).toEqual([['i/.gitignore', 0, 2, 0], ['i/i.txt', 0, 2, 0]])
84
81
@@ -93,54 +90,35 @@ describe('statusMatrix', () => {
93
90
])
94
91
})
95
92
96
-
it('statusMatrix (pattern vs pattern + filepaths)', async () => {
93
+
it('statusMatrix with filter', async () => {
97
94
// Setup
98
95
const { dir, gitdir } = await makeFixture('test-statusMatrix-filepath')
99
96
// Test
100
-
let matrix = await statusMatrix({ dir, gitdir, pattern: '*.txt' })
101
-
expect(matrix).toEqual([
102
-
['a.txt', 1, 1, 1],
103
-
['b.txt', 1, 2, 1],
104
-
['c.txt', 1, 0, 1],
105
-
['d.txt', 0, 2, 0]
106
-
])
107
-
108
-
matrix = await statusMatrix({
97
+
let matrix = await statusMatrix({
109
98
dir,
110
99
gitdir,
111
-
pattern: '*.txt',
112
-
filepaths: ['i']
113
-
})
114
-
expect(matrix).toEqual([['i/i.txt', 0, 2, 0]])
115
-
116
-
matrix = await statusMatrix({
117
-
dir,
118
-
gitdir,
119
-
pattern: '*.txt',
120
-
filepaths: ['.', 'i']
100
+
filter: filepath => !filepath.includes('/') && filepath.endsWith('.txt')
121
101
})
122
102
expect(matrix).toEqual([
123
103
['a.txt', 1, 1, 1],
124
104
['b.txt', 1, 2, 1],
125
105
['c.txt', 1, 0, 1],
126
-
['d.txt', 0, 2, 0],
127
-
['i/i.txt', 0, 2, 0]
106
+
['d.txt', 0, 2, 0]
128
107
])
129
108
130
109
matrix = await statusMatrix({
131
110
dir,
132
111
gitdir,
133
-
pattern: 'i/*.txt',
134
-
filepaths: ['.', 'i']
112
+
filter: filepath => filepath.endsWith('.gitignore')
135
113
})
136
-
expect(matrix).toEqual([['i/i.txt', 0, 2, 0]])
114
+
expect(matrix).toEqual([['i/.gitignore', 0, 2, 0]])
137
115
138
116
matrix = await statusMatrix({
139
117
dir,
140
118
gitdir,
141
-
pattern: 'i/*.txt',
119
+
filter: filepath => filepath.endsWith('.txt'),
142
120
filepaths: ['i']
143
121
})
144
-
expect(matrix).toEqual([])
122
+
expect(matrix).toEqual([['i/i.txt', 0, 2, 0]])
145
123
})
146
124
})
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4