Skip to content

Commit

Permalink
tests: Add test with multiple negate groups
Browse files Browse the repository at this point in the history
Validate that a filter with multiple negate groups works as expected.

Signed-off-by: Jarno Rajahalme <[email protected]>
  • Loading branch information
jrajahalme committed May 12, 2023
1 parent 4067d88 commit d2834fd
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions __tests__/filter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,26 @@ describe('matching tests', () => {
expect(pyMatch.backend).toEqual(pyFiles)
})

test('matches all except tests or docs and tsx or less files (multiple negate groups)', () => {
const yaml = `
backend:
- '!(test|docs)/**/!(*.tsx|*.less)'
`
const filter = new Filter(yaml)
const tsxFiles = modified(['src/ui.tsx'])
const lessFiles = modified(['src/ui.less'])
const pyFiles = modified(['src/server.py', 'test/test.py', 'test/test.less', 'docs/readme.txt', 'src/server.tsx', 'src/client.py'])
const srcFiles = modified(['src/server.py', 'src/client.py'])

const tsxMatch = filter.match(tsxFiles)
const lessMatch = filter.match(lessFiles)
const pyMatch = filter.match(pyFiles)

expect(tsxMatch.backend).toEqual([])
expect(lessMatch.backend).toEqual([])
expect(pyMatch.backend).toEqual(srcFiles)
})

test('matches path based on rules included using YAML anchor', () => {
const yaml = `
shared: &shared
Expand Down

0 comments on commit d2834fd

Please sign in to comment.