import { describe, it, expect, vi, beforeEach } from "vitest"; import { NotificationType } from "./types"; import { claudeStore } from "$lib/stores/claude"; import { sendTerminalNotification } from "./terminalNotifier"; vi.mock("$lib/stores/claude", () => ({ claudeStore: { addLine: vi.fn(), }, })); describe("sendTerminalNotification", () => { beforeEach(() => { vi.clearAllMocks(); }); it("adds a system line for success type with sparkle emoji", () => { sendTerminalNotification(NotificationType.SUCCESS); expect(claudeStore.addLine).toHaveBeenCalledWith("system", expect.stringContaining("✨")); }); it("adds a system line for error type with cross emoji", () => { sendTerminalNotification(NotificationType.ERROR); expect(claudeStore.addLine).toHaveBeenCalledWith("system", expect.stringContaining("❌")); }); it("adds a system line for permission type with lock emoji", () => { sendTerminalNotification(NotificationType.PERMISSION); expect(claudeStore.addLine).toHaveBeenCalledWith("system", expect.stringContaining("🔐")); }); it("adds a system line for connection type with link emoji", () => { sendTerminalNotification(NotificationType.CONNECTION); expect(claudeStore.addLine).toHaveBeenCalledWith("system", expect.stringContaining("🔗")); }); it("adds a system line for task_start type with rocket emoji", () => { sendTerminalNotification(NotificationType.TASK_START); expect(claudeStore.addLine).toHaveBeenCalledWith("system", expect.stringContaining("🚀")); }); it("includes the optional message in the notification", () => { sendTerminalNotification(NotificationType.SUCCESS, "Custom message text"); expect(claudeStore.addLine).toHaveBeenCalledWith( "system", expect.stringContaining("Custom message text") ); }); it("includes the sound phrase as the notification title", () => { sendTerminalNotification(NotificationType.SUCCESS); expect(claudeStore.addLine).toHaveBeenCalledWith( "system", expect.stringContaining("I'm done!") ); }); });