Skip to content

Commit 6848dbb

Browse files
Update test to return null instead of throwing an error when there are no changes
- Modified the test case to expect getGitSummary to return null when there are no changes instead of throwing an error. - Updated the mock implementation
1 parent 3543a34 commit 6848dbb

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

tests/index.test.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,13 @@ describe('Git GPT Commit', () => {
7878
expect(gitGptCommit.getGitSummary).toHaveBeenCalled()
7979
})
8080

81-
it('throws an error when there are no changes', async () => {
81+
it('returns null when there are no changes', async () => {
8282
// Temporarily modify the mock to simulate no changes
83-
vi.mocked(gitGptCommit.getGitSummary).mockImplementationOnce(() => {
84-
throw new Error('No changes to commit')
85-
})
83+
vi.mocked(gitGptCommit.getGitSummary).mockResolvedValueOnce(null)
8684

8785
// Call getGitSummary with no changes
88-
expect(async () => gitGptCommit.getGitSummary()).toThrow(
89-
'No changes to commit',
90-
)
86+
const result = await gitGptCommit.getGitSummary()
87+
expect(result).toBeNull()
9188
})
9289
})
9390

0 commit comments

Comments
 (0)