Skip to content

Commit

Permalink
chore: improve test coverage (#1440)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 committed Aug 7, 2023
1 parent 0acc1c3 commit 87697c0
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
it('should return an empty object when there are no files that match the file patterns', async () => {
const allDiffFiles = {
Expand Down

0 comments on commit 87697c0

Please sign in to comment.