mirror of
https://github.com/dorny/paths-filter.git
synced 2025-06-09 10:39:05 +00:00
Add tests for the filter with negation
This commit is contained in:
parent
6706fee383
commit
5af776fb70
2 changed files with 31 additions and 41 deletions
__tests__
|
@ -117,6 +117,37 @@ describe('matching tests', () => {
|
|||
expect(pyMatch.backend).toEqual(pyFiles)
|
||||
})
|
||||
|
||||
test('matches single rule with negation', () => {
|
||||
const yaml = `
|
||||
src:
|
||||
- '!src/**/*.js'
|
||||
`
|
||||
const filter = new Filter(yaml)
|
||||
const files = modified(['src/app/module/file.js'])
|
||||
const match = filter.match(files)
|
||||
expect(match.src).toEqual([])
|
||||
})
|
||||
|
||||
test('matches multiple rules with negation', () => {
|
||||
const yaml = `
|
||||
src:
|
||||
- 'src/**/*.ts'
|
||||
- '!src/**/*.test.ts'
|
||||
`
|
||||
const filter = new Filter(yaml)
|
||||
const jsFiles = modified(['src/app/module/file.js'])
|
||||
const tsFiles = modified(['src/app/module/file.ts'])
|
||||
const tsTestFiles = modified(['src/app/module/file.test.ts'])
|
||||
|
||||
const jsMatch = filter.match(jsFiles)
|
||||
const tsMatch = filter.match(tsFiles)
|
||||
const tsTestMatch = filter.match(tsTestFiles)
|
||||
|
||||
expect(jsMatch.src).toEqual([])
|
||||
expect(tsMatch.src).toEqual(tsFiles)
|
||||
expect(tsTestMatch.src).toEqual([])
|
||||
})
|
||||
|
||||
test('matches path based on rules included using YAML anchor', () => {
|
||||
const yaml = `
|
||||
shared: &shared
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue