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

Add more test for user better understand the behavior in CI pipeline #245

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
31 changes: 31 additions & 0 deletions __tests__/filter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,37 @@ describe('matching specific change status', () => {
const match = filter.match(files)
expect(match.src).toEqual(files)
})

test('use of OR operation', () => {
const yaml = `
backend:
- 'src/*.tsx|src/*.less'
`
const filter = new Filter(yaml)
const tsxFiles = modified(['src/ui.tsx'])
const lessFiles = modified(['src/ui.less'])
const pyFiles = modified(['src/server.py'])

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

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

test('matches non change of dir)', () => {
const yaml = `
backend:
- '!docs/**'
`
const filter = new Filter(yaml)

const nonDocsFiles = modified(['src/ui.tsx'])
const nonDocsMatch = filter.match(nonDocsFiles)
expect(nonDocsMatch.backend).toEqual(nonDocsFiles)
})
})

function modified(paths: string[]): File[] {
Expand Down