Skip to content

Commit a14b7f3

Browse files
test: 修正 mock 的滥用情况
1 parent c5ab83a commit a14b7f3

15 files changed

Lines changed: 11 additions & 844 deletions

File tree

packages/builtin-tools/src/tools/AgentTool/__tests__/agentToolUtils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ mock.module("src/tasks/LocalAgentTask/LocalAgentTask.js", () => ({
8787
updateProgressFromMessage: noop,
8888
}));
8989

90-
mock.module("src/utils/debug.js", () => ({
90+
mock.module("src/utils/debug.ts", () => ({
9191
getMinDebugLogLevel: () => "warn",
9292
isDebugMode: () => false,
9393
enableDebugLogging: () => false,

packages/builtin-tools/src/tools/BashTool/__tests__/commandSemantics.test.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import { mock, describe, expect, test } from "bun:test";
2-
3-
// Mock commands.ts to cut the heavy shell/prefix.ts → analytics → api chain
4-
mock.module("src/utils/bash/commands.ts", () => ({
5-
splitCommand_DEPRECATED: (cmd: string) =>
6-
cmd.split(/\s*(?:[|;&]+)\s*/).filter(Boolean),
7-
quote: (args: string[]) => args.join(" "),
8-
}));
1+
import { describe, expect, test } from "bun:test";
92

103
const { interpretCommandResult } = await import("../commandSemantics");
114

packages/builtin-tools/src/tools/LSPTool/__tests__/formatters.test.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
import { mock, describe, expect, test } from "bun:test";
22

3-
mock.module("src/utils/debug.js", () => ({
3+
mock.module("src/utils/debug.ts", () => ({
44
logForDebugging: () => {},
55
isDebugMode: () => false,
66
}));
77

8-
mock.module("src/utils/errors.js", () => ({
9-
errorMessage: (e: unknown) => String(e),
10-
}));
11-
12-
mock.module("src/utils/stringUtils.js", () => ({
13-
plural: (n: number, singular: string, plural?: string) =>
14-
n === 1 ? singular : (plural ?? singular + "s"),
15-
}));
16-
178
const {
189
formatGoToDefinitionResult,
1910
formatFindReferencesResult,

src/services/acp/__tests__/agent.test.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,7 @@ mock.module('../../../Tool.js', () => ({
2626
buildTool: mock((def: any) => def),
2727
}))
2828

29-
mock.module('../../../utils/config.js', () => ({
30-
enableConfigs: mock(() => {}),
31-
}))
32-
33-
// Also mock via src/ alias to prevent alias resolution corruption for other test files.
34-
// See: agent.test.ts's relative-path mock for config.js breaks Bun's src/* path
35-
// alias for subsequent test files (Cannot find module 'src/utils/errors.js' etc.)
36-
mock.module('src/utils/config.js', () => ({
29+
mock.module('src/utils/config.ts', () => ({
3730
enableConfigs: mock(() => {}),
3831
}))
3932

0 commit comments

Comments
 (0)