Skip to content

Commit 8c84c3f

Browse files
committed
Use vitest instead
1 parent e756498 commit 8c84c3f

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

src/core/tools/__tests__/searchFilesTool.test.ts renamed to src/core/tools/__tests__/searchFilesTool.spec.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import path from "path"
2+
import { describe, it, expect, beforeEach, vi, type Mock, type MockedFunction } from "vitest"
23
import { searchFilesTool } from "../searchFilesTool"
34
import { Task } from "../../task/Task"
45
import { SearchFilesToolUse } from "../../../shared/tools"
@@ -7,45 +8,45 @@ import { regexSearchFiles } from "../../../services/ripgrep"
78
import { RooIgnoreController } from "../../ignore/RooIgnoreController"
89

910
// Mock dependencies
10-
jest.mock("../../../utils/pathUtils", () => ({
11-
isPathOutsideWorkspace: jest.fn(),
11+
vi.mock("../../../utils/pathUtils", () => ({
12+
isPathOutsideWorkspace: vi.fn(),
1213
}))
1314

14-
jest.mock("../../../services/ripgrep", () => ({
15-
regexSearchFiles: jest.fn(),
15+
vi.mock("../../../services/ripgrep", () => ({
16+
regexSearchFiles: vi.fn(),
1617
}))
1718

18-
jest.mock("../../../utils/path", () => ({
19-
getReadablePath: jest.fn((cwd: string, relPath: string) => relPath),
19+
vi.mock("../../../utils/path", () => ({
20+
getReadablePath: vi.fn((cwd: string, relPath: string) => relPath),
2021
}))
2122

22-
jest.mock("../../ignore/RooIgnoreController")
23+
vi.mock("../../ignore/RooIgnoreController")
2324

24-
const mockedIsPathOutsideWorkspace = isPathOutsideWorkspace as jest.MockedFunction<typeof isPathOutsideWorkspace>
25-
const mockedRegexSearchFiles = regexSearchFiles as jest.MockedFunction<typeof regexSearchFiles>
25+
const mockedIsPathOutsideWorkspace = isPathOutsideWorkspace as MockedFunction<typeof isPathOutsideWorkspace>
26+
const mockedRegexSearchFiles = regexSearchFiles as MockedFunction<typeof regexSearchFiles>
2627

2728
describe("searchFilesTool", () => {
2829
let mockTask: Partial<Task>
29-
let mockAskApproval: jest.Mock
30-
let mockHandleError: jest.Mock
31-
let mockPushToolResult: jest.Mock
32-
let mockRemoveClosingTag: jest.Mock
30+
let mockAskApproval: Mock
31+
let mockHandleError: Mock
32+
let mockPushToolResult: Mock
33+
let mockRemoveClosingTag: Mock
3334

3435
beforeEach(() => {
35-
jest.clearAllMocks()
36+
vi.clearAllMocks()
3637

3738
mockTask = {
3839
cwd: "/workspace",
3940
consecutiveMistakeCount: 0,
40-
recordToolError: jest.fn(),
41-
sayAndCreateMissingParamError: jest.fn().mockResolvedValue("Missing parameter error"),
41+
recordToolError: vi.fn(),
42+
sayAndCreateMissingParamError: vi.fn().mockResolvedValue("Missing parameter error"),
4243
rooIgnoreController: new RooIgnoreController("/workspace"),
4344
}
4445

45-
mockAskApproval = jest.fn().mockResolvedValue(true)
46-
mockHandleError = jest.fn()
47-
mockPushToolResult = jest.fn()
48-
mockRemoveClosingTag = jest.fn((tag: string, value: string | undefined) => value || "")
46+
mockAskApproval = vi.fn().mockResolvedValue(true)
47+
mockHandleError = vi.fn()
48+
mockPushToolResult = vi.fn()
49+
mockRemoveClosingTag = vi.fn((tag: string, value: string | undefined) => value || "")
4950

5051
mockedRegexSearchFiles.mockResolvedValue("Search results")
5152
})
@@ -232,7 +233,7 @@ describe("searchFilesTool", () => {
232233
partial: true,
233234
}
234235

235-
const mockAsk = jest.fn()
236+
const mockAsk = vi.fn()
236237
mockTask.ask = mockAsk
237238

238239
await searchFilesTool(

0 commit comments

Comments
 (0)