diff --git a/src/hooks/auto-slash-command/index.test.ts b/src/hooks/auto-slash-command/index.test.ts index 42edb13..ac8033b 100644 --- a/src/hooks/auto-slash-command/index.test.ts +++ b/src/hooks/auto-slash-command/index.test.ts @@ -1,33 +1,16 @@ -import { describe, expect, it, beforeEach, mock } from "bun:test" +import { describe, expect, it, beforeEach, mock, spyOn } from "bun:test" import type { AutoSlashCommandHookInput, AutoSlashCommandHookOutput, } from "./types" -const logMock = mock(() => {}) +// Import real shared module to avoid mock leaking to other test files +import * as shared from "../../shared" -mock.module("../../shared", () => ({ - log: logMock, - parseFrontmatter: (content: string) => ({ data: {}, body: content }), - resolveCommandsInText: async (text: string) => text, - resolveFileReferencesInText: async (text: string) => text, - sanitizeModelField: (model: unknown) => model, - getClaudeConfigDir: () => "/mock/.claude", -})) +// Spy on log instead of mocking the entire module +const logMock = spyOn(shared, "log").mockImplementation(() => {}) -mock.module("../../shared/file-utils", () => ({ - isMarkdownFile: () => false, -})) -mock.module("../../features/opencode-skill-loader", () => ({ - discoverAllSkills: () => [], -})) - -mock.module("fs", () => ({ - existsSync: () => false, - readdirSync: () => [], - readFileSync: () => "", -})) const { createAutoSlashCommandHook } = await import("./index") diff --git a/src/hooks/think-mode/index.test.ts b/src/hooks/think-mode/index.test.ts index 0579122..8d319d7 100644 --- a/src/hooks/think-mode/index.test.ts +++ b/src/hooks/think-mode/index.test.ts @@ -1,12 +1,6 @@ -import { describe, expect, it, beforeEach, mock } from "bun:test" +import { describe, expect, it, beforeEach } from "bun:test" import type { ThinkModeInput } from "./types" -const logMock = mock(() => {}) - -mock.module("../../shared", () => ({ - log: logMock, -})) - const { createThinkModeHook, clearThinkModeState } = await import("./index") /**