Files
oh-my-pi/packages/coding-agent/test/modes/theme/shimmer.test.ts
T
can1357 b8e4da23d0 ci(ci): refactored CI setup and test-state isolation for coding-agent workflows
- Added a setup-system-deps action with preloaded-runner guards and apt fallbacks.
- Updated CI workflows to download Linux x64 native artifacts and gate on native job success.
- Renamed coding-agent fast mode to singleton in scripts and test partitioning logic.
- Added settings test-state begin/restore helpers with recursive cleanup in affected tests.
2026-06-14 22:37:05 +02:00

45 lines
1.4 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "bun:test";
import * as settingsModule from "@oh-my-pi/pi-coding-agent/config/settings";
import { shimmerText } from "@oh-my-pi/pi-coding-agent/modes/theme/shimmer";
import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme";
const testTheme = {
bold(text: string): string {
return `\x1b[1m${text}\x1b[22m`;
},
fg(color: Parameters<Theme["fg"]>[0], text: string): string {
return `${this.getFgAnsi(color)}${text}\x1b[39m`;
},
getFgAnsi(color: Parameters<Theme["getFgAnsi"]>[0]): string {
const codes = {
accent: "\x1b[36m",
dim: "\x1b[2m",
muted: "\x1b[90m",
};
return codes[color as "accent" | "dim" | "muted"] ?? "";
},
};
describe("shimmerText", () => {
afterEach(() => {
vi.restoreAllMocks();
});
it("uses a supplied raw ANSI color for the shimmer crest", () => {
vi.spyOn(settingsModule, "isSettingsInitialized").mockReturnValue(false);
// t chosen so the fixed-velocity band (30 cells/s) crest sits on the char:
// pos = (333/1000)*30 ≈ 10 = CLASSIC_PADDING, i.e. centered on index 0.
vi.spyOn(Date, "now").mockReturnValue(333);
const rendered = shimmerText("x", testTheme, {
low: "dim",
mid: { ansi: "\x1b[38;2;12;34;56m" },
high: { ansi: "\x1b[38;2;12;34;56m" },
bold: true,
});
expect(rendered).toContain("\x1b[38;2;12;34;56m");
expect(Bun.stripANSI(rendered)).toBe("x");
});
});