Skip to content

Commit 53e828b

Browse files
committed
fix: update test mocks to support diagnostic settings in tool tests
- Add providerRef mock to insertContentTool and writeToFileTool tests - Update mocks to include diagnosticsEnabled and diagnosticsDelayMs settings - Fix test expectations to match new implementation with diagnostic configuration - Resolves failing unit tests for insertContentTool.spec.ts and writeToFileTool.spec.ts
1 parent a1e7983 commit 53e828b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/core/tools/__tests__/insertContentTool.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ describe("insertContentTool", () => {
7171
cwd: "/",
7272
consecutiveMistakeCount: 0,
7373
didEditFile: false,
74+
providerRef: {
75+
deref: vi.fn().mockReturnValue({
76+
getState: vi.fn().mockResolvedValue({
77+
diagnosticsEnabled: true,
78+
diagnosticsDelayMs: 2000,
79+
}),
80+
}),
81+
},
7482
rooIgnoreController: {
7583
validateAccess: vi.fn().mockReturnValue(true),
7684
},

src/core/tools/__tests__/writeToFileTool.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ describe("writeToFileTool", () => {
132132
mockCline.consecutiveMistakeCount = 0
133133
mockCline.didEditFile = false
134134
mockCline.diffStrategy = undefined
135+
mockCline.providerRef = {
136+
deref: vi.fn().mockReturnValue({
137+
getState: vi.fn().mockResolvedValue({
138+
diagnosticsEnabled: true,
139+
diagnosticsDelayMs: 2000,
140+
}),
141+
}),
142+
}
135143
mockCline.rooIgnoreController = {
136144
validateAccess: vi.fn().mockReturnValue(true),
137145
}
@@ -376,7 +384,7 @@ describe("writeToFileTool", () => {
376384
userEdits: userEditsValue,
377385
finalContent: "modified content",
378386
})
379-
// Manually set the property on the mock instance because the original saveChanges is not called
387+
// Set the userEdits property on the diffViewProvider mock to simulate user edits
380388
mockCline.diffViewProvider.userEdits = userEditsValue
381389

382390
await executeWriteFileTool({}, { fileExists: true })

0 commit comments

Comments
 (0)