Skip to content

Commit d2834fd

Browse files
committed
tests: Add test with multiple negate groups
Validate that a filter with multiple negate groups works as expected. Signed-off-by: Jarno Rajahalme <[email protected]>
1 parent 4067d88 commit d2834fd

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

__tests__/filter.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,26 @@ describe('matching tests', () => {
117117
expect(pyMatch.backend).toEqual(pyFiles)
118118
})
119119

120+
test('matches all except tests or docs and tsx or less files (multiple negate groups)', () => {
121+
const yaml = `
122+
backend:
123+
- '!(test|docs)/**/!(*.tsx|*.less)'
124+
`
125+
const filter = new Filter(yaml)
126+
const tsxFiles = modified(['src/ui.tsx'])
127+
const lessFiles = modified(['src/ui.less'])
128+
const pyFiles = modified(['src/server.py', 'test/test.py', 'test/test.less', 'docs/readme.txt', 'src/server.tsx', 'src/client.py'])
129+
const srcFiles = modified(['src/server.py', 'src/client.py'])
130+
131+
const tsxMatch = filter.match(tsxFiles)
132+
const lessMatch = filter.match(lessFiles)
133+
const pyMatch = filter.match(pyFiles)
134+
135+
expect(tsxMatch.backend).toEqual([])
136+
expect(lessMatch.backend).toEqual([])
137+
expect(pyMatch.backend).toEqual(srcFiles)
138+
})
139+
120140
test('matches path based on rules included using YAML anchor', () => {
121141
const yaml = `
122142
shared: &shared

0 commit comments

Comments
 (0)