Skip to content

Commit 3d3e537

Browse files
committed
test(mocks,config): update mocks and test configs for withProgress API
- Add withProgress mock implementation to vscode mock - Add ProgressLocation enum to vscode mock - Update temperature value from 0.4 to 0.3 in tests - Remove unnecessary async/await from activate() calls - Update test assertions for configuration handling
1 parent 1b497b0 commit 3d3e537

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

test/__mocks__/vscode.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ const mockWindow = {
4545
show: jest.fn(),
4646
dispose: jest.fn(),
4747
}),
48+
withProgress: jest.fn().mockImplementation((options, task) => {
49+
return task({
50+
report: jest.fn(),
51+
})
52+
}),
4853
}
4954

5055
const mockExtensions = {
@@ -74,3 +79,8 @@ export const Uri = {
7479
// Export any additional VSCode APIs that tests need
7580
export const EventEmitter = jest.fn()
7681
export const TextDocument = jest.fn()
82+
export const ProgressLocation = {
83+
Notification: 1,
84+
SourceControl: 2,
85+
Window: 3,
86+
}

test/configurationEdgeCases.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe("Configuration Edge Cases", () => {
6262
mockConfig = {
6363
model: "claude-3-5-sonnet-latest",
6464
maxTokens: 1024,
65-
temperature: 0.4,
65+
temperature: 0.3,
6666
allowedTypes: ["feat", "fix", "refactor", "chore", "docs", "style", "test", "perf", "ci"],
6767
}
6868

@@ -185,7 +185,7 @@ describe("Configuration Edge Cases", () => {
185185

186186
expect(mockAnthropicCreate).toHaveBeenCalledWith(
187187
expect.objectContaining({
188-
temperature: 0.4,
188+
temperature: 0.3,
189189
}),
190190
)
191191
})

test/configurationHandling.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe("Configuration Handling", () => {
7979
return config[key]
8080
})
8181

82-
await activate(mockContext)
82+
activate(mockContext)
8383
await vscode.commands.executeCommand("diffCommit.generateCommitMessage")
8484

8585
expect(configGetMock).toHaveBeenCalledWith("model")
@@ -92,7 +92,7 @@ describe("Configuration Handling", () => {
9292
test("should use default values when configuration is missing", async () => {
9393
configGetMock.mockReturnValue(undefined)
9494

95-
await activate(mockContext)
95+
activate(mockContext)
9696
await vscode.commands.executeCommand("diffCommit.generateCommitMessage")
9797

9898
expect(configGetMock).toHaveBeenCalled()
@@ -106,7 +106,7 @@ describe("Configuration Handling", () => {
106106
return undefined
107107
})
108108

109-
await activate(mockContext)
109+
activate(mockContext)
110110
await vscode.commands.executeCommand("diffCommit.generateCommitMessage")
111111

112112
expect(configGetMock).toHaveBeenCalledWith("customInstructions")
@@ -115,7 +115,7 @@ describe("Configuration Handling", () => {
115115
test("should handle missing workspace folder", async () => {
116116
;(vscode.workspace.workspaceFolders as any) = undefined
117117

118-
await activate(mockContext)
118+
activate(mockContext)
119119
await vscode.commands.executeCommand("diffCommit.generateCommitMessage")
120120

121121
expect(vscode.window.showErrorMessage).toHaveBeenCalledWith("No workspace folder found")
@@ -124,7 +124,7 @@ describe("Configuration Handling", () => {
124124
test("should handle missing Git extension", async () => {
125125
;(vscode.extensions.getExtension as jest.Mock).mockReturnValue(undefined)
126126

127-
await activate(mockContext)
127+
activate(mockContext)
128128
await vscode.commands.executeCommand("diffCommit.generateCommitMessage")
129129

130130
expect(vscode.window.showErrorMessage).toHaveBeenCalledWith("Git extension not found")
@@ -146,7 +146,7 @@ describe("Configuration Handling", () => {
146146
return undefined
147147
})
148148

149-
await activate(mockContext)
149+
activate(mockContext)
150150
await vscode.commands.executeCommand("diffCommit.generateCommitMessage")
151151

152152
expect(vscode.window.showErrorMessage).toHaveBeenCalledWith("No Git repository found")
@@ -178,7 +178,7 @@ describe("Configuration Handling", () => {
178178
return undefined
179179
})
180180

181-
await activate(mockContext)
181+
activate(mockContext)
182182
await vscode.commands.executeCommand("diffCommit.generateCommitMessage")
183183

184184
expect(vscode.window.showErrorMessage).toHaveBeenCalledWith("No changes detected")

0 commit comments

Comments
 (0)