From 87697c0dca7dd44e37a2b79a79489332556ff1f3 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 7 Aug 2023 00:05:28 -0600 Subject: [PATCH] chore: improve test coverage (#1440) --- src/__tests__/utils.test.ts | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/__tests__/utils.test.ts b/src/__tests__/utils.test.ts index d4ec17503ef..bccbfa426be 100644 --- a/src/__tests__/utils.test.ts +++ b/src/__tests__/utils.test.ts @@ -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 = {