import { afterEach, beforeAll, describe, expect, it, vi } from "bun:test"; import { Settings } from "@oh-my-pi/pi-coding-agent/config/settings"; import { WelcomeComponent } from "@oh-my-pi/pi-coding-agent/modes/components/welcome"; import { initTheme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; describe("WelcomeComponent tips", () => { beforeAll(async () => { await Settings.init({ inMemory: true }); await initTheme(false); }); afterEach(() => { vi.restoreAllMocks(); }); it("selects standard tip when preset is not unicode", () => { vi.spyOn(theme, "getSymbolPreset").mockReturnValue("nerd"); const welcome = new WelcomeComponent("1.0.0", "model", "provider"); expect(welcome.tip).not.toBe("Please use nerdfont 😭."); expect(welcome.tip).toBeDefined(); }); it("selects nerdfont tip with 10% probability under unicode preset", () => { vi.spyOn(theme, "getSymbolPreset").mockReturnValue("unicode"); // 9% chance => selects special tip vi.spyOn(Math, "random").mockReturnValue(0.09); const welcomeSpecial = new WelcomeComponent("1.0.0", "model", "provider"); expect(welcomeSpecial.tip).toBe("Please use nerdfont 😭."); // 10% chance => selects regular tip vi.spyOn(Math, "random").mockReturnValue(0.1); const welcomeRegular = new WelcomeComponent("1.0.0", "model", "provider"); expect(welcomeRegular.tip).not.toBe("Please use nerdfont 😭."); expect(welcomeRegular.tip).toBeDefined(); }); });