Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Add test with multiple negate groups #191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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