mirror of
https://github.com/tj-actions/changed-files
synced 2025-03-05 21:06:25 +00:00
chore: improve test coverage (#1440)
This commit is contained in:
parent
0acc1c308e
commit
87697c0dca
1 changed files with 40 additions and 0 deletions
|
@ -347,6 +347,46 @@ describe('utils test', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Tests that the function returns only the files that match the file patterns with globstar
|
||||||
|
it('should return only the files that match the file patterns with globstar', async () => {
|
||||||
|
const allDiffFiles = {
|
||||||
|
[ChangeTypeEnum.Added]: [
|
||||||
|
'file1.txt',
|
||||||
|
'file2.md',
|
||||||
|
'file3.txt',
|
||||||
|
'test/dir/file4.txt',
|
||||||
|
'/test/dir/file5.txt',
|
||||||
|
'dir/file6.md'
|
||||||
|
],
|
||||||
|
[ChangeTypeEnum.Copied]: [],
|
||||||
|
[ChangeTypeEnum.Deleted]: [],
|
||||||
|
[ChangeTypeEnum.Modified]: [],
|
||||||
|
[ChangeTypeEnum.Renamed]: [],
|
||||||
|
[ChangeTypeEnum.TypeChanged]: [],
|
||||||
|
[ChangeTypeEnum.Unmerged]: [],
|
||||||
|
[ChangeTypeEnum.Unknown]: []
|
||||||
|
}
|
||||||
|
const result = await getFilteredChangedFiles({
|
||||||
|
allDiffFiles,
|
||||||
|
filePatterns: ['**.txt']
|
||||||
|
})
|
||||||
|
expect(result).toEqual({
|
||||||
|
[ChangeTypeEnum.Added]: [
|
||||||
|
'file1.txt',
|
||||||
|
'file3.txt',
|
||||||
|
'test/dir/file4.txt',
|
||||||
|
'/test/dir/file5.txt'
|
||||||
|
],
|
||||||
|
[ChangeTypeEnum.Copied]: [],
|
||||||
|
[ChangeTypeEnum.Deleted]: [],
|
||||||
|
[ChangeTypeEnum.Modified]: [],
|
||||||
|
[ChangeTypeEnum.Renamed]: [],
|
||||||
|
[ChangeTypeEnum.TypeChanged]: [],
|
||||||
|
[ChangeTypeEnum.Unmerged]: [],
|
||||||
|
[ChangeTypeEnum.Unknown]: []
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// Tests that the function returns an empty object when there are no files that match the file patterns
|
// Tests that the function returns an empty object when there are no files that match the file patterns
|
||||||
it('should return an empty object when there are no files that match the file patterns', async () => {
|
it('should return an empty object when there are no files that match the file patterns', async () => {
|
||||||
const allDiffFiles = {
|
const allDiffFiles = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue