mirror of
https://github.com/dorny/paths-filter.git
synced 2025-06-08 10:01:34 +00:00
Collect and report number of changes
This commit is contained in:
parent
de90cc6fb3
commit
28cec18b46
11 changed files with 374 additions and 169 deletions
|
@ -181,7 +181,7 @@ describe('matching specific change status', () => {
|
|||
- added: "**/*"
|
||||
`
|
||||
let filter = new Filter(yaml)
|
||||
const files = [{status: ChangeStatus.Added, filename: 'file.js'}]
|
||||
const files = [{status: ChangeStatus.Added, filename: 'file.js', additions: 1, deletions: 0}]
|
||||
const match = filter.match(files)
|
||||
expect(match.add).toEqual(files)
|
||||
})
|
||||
|
@ -192,7 +192,7 @@ describe('matching specific change status', () => {
|
|||
- added|modified: "**/*"
|
||||
`
|
||||
let filter = new Filter(yaml)
|
||||
const files = [{status: ChangeStatus.Modified, filename: 'file.js'}]
|
||||
const files = [{status: ChangeStatus.Modified, filename: 'file.js', additions: 1, deletions: 1}]
|
||||
const match = filter.match(files)
|
||||
expect(match.addOrModify).toEqual(files)
|
||||
})
|
||||
|
@ -214,12 +214,6 @@ describe('matching specific change status', () => {
|
|||
|
||||
function modified(paths: string[]): File[] {
|
||||
return paths.map(filename => {
|
||||
return {filename, status: ChangeStatus.Modified}
|
||||
})
|
||||
}
|
||||
|
||||
function renamed(paths: string[]): File[] {
|
||||
return paths.map(filename => {
|
||||
return {filename, status: ChangeStatus.Renamed}
|
||||
return {filename, status: ChangeStatus.Modified, additions: 1, deletions: 1}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ import * as git from '../src/git'
|
|||
import {ChangeStatus} from '../src/file'
|
||||
|
||||
describe('parsing output of the git diff command', () => {
|
||||
test('parseGitDiffOutput returns files with correct change status', async () => {
|
||||
const files = git.parseGitDiffOutput(
|
||||
test('parseGitDiffNameStatusOutput returns files with correct change status', async () => {
|
||||
const files = git.parseGitDiffNameStatusOutput(
|
||||
'A\u0000LICENSE\u0000' + 'M\u0000src/index.ts\u0000' + 'D\u0000src/main.ts\u0000'
|
||||
)
|
||||
expect(files.length).toBe(3)
|
||||
|
@ -14,6 +14,17 @@ describe('parsing output of the git diff command', () => {
|
|||
expect(files[2].filename).toBe('src/main.ts')
|
||||
expect(files[2].status).toBe(ChangeStatus.Deleted)
|
||||
})
|
||||
|
||||
test('parseGitDiffNumstatOutput returns files with correct change status', async () => {
|
||||
const files = git.parseGitDiffNumstatOutput('4\t2\tLICENSE\u0000' + '5\t0\tsrc/index.ts\u0000')
|
||||
expect(files.length).toBe(2)
|
||||
expect(files[0].filename).toBe('LICENSE')
|
||||
expect(files[0].additions).toBe(4)
|
||||
expect(files[0].deletions).toBe(2)
|
||||
expect(files[1].filename).toBe('src/index.ts')
|
||||
expect(files[1].additions).toBe(5)
|
||||
expect(files[1].deletions).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('git utility function tests (those not invoking git)', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue