Files
oh-my-pi/packages/coding-agent/test/slash-command-format.test.ts
T
can1357 e39b48c405 feat(coding-agent): added shimmer modes and tuned loader timing cadence
- Added `display.shimmer` setting (`classic`, `kitt`, `disabled`) with default `classic` and UI metadata.
- Added shimmer mode resolution with defaulting plus classic/KITT intensity tier profiles and thresholds.
- Added `getFgAnsi` handling across shimmer compilation and progress-bar themes, with fallback ANSI output defaults.
- Reworked shimmer rendering to coalesce same-tier segments, cache palettes by symbol, and map disabled mode to mid-tier.
- Tuned loader timing to a 16ms render interval and 80ms spinner stepping for smoother ~60fps updates.
2026-05-22 13:03:03 +09:00

49 lines
1.3 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "bun:test";
import type { Theme } from "../src/modes/theme/theme";
import { renderAsciiBar } from "../src/slash-commands/helpers/format";
const testTheme = {
fg(color: Parameters<Theme["fg"]>[0], text: string): string {
const codes = {
accent: "\x1b[36m",
dim: "\x1b[2m",
muted: "\x1b[90m",
};
return `${codes[color as "accent" | "dim" | "muted"] ?? ""}${text}\x1b[39m`;
},
bold(text: string): string {
return `\x1b[1m${text}\x1b[22m`;
},
getFgAnsi(color: Parameters<Theme["fg"]>[0]): string {
const codes = {
accent: "\x1b[36m",
dim: "\x1b[2m",
muted: "\x1b[90m",
};
return codes[color as "accent" | "dim" | "muted"] ?? "";
},
};
describe("renderAsciiBar", () => {
afterEach(() => {
vi.restoreAllMocks();
});
it("preserves the visible progress-bar contract", () => {
vi.spyOn(Date, "now").mockReturnValue(834);
const rendered = renderAsciiBar(0.5, 4, testTheme);
expect(Bun.stripANSI(rendered)).toBe("[██░░] 50%");
});
it("colors the shimmer band with the theme accent", () => {
vi.spyOn(Date, "now").mockReturnValue(834);
const rendered = renderAsciiBar(undefined, 4, testTheme);
expect(rendered).toContain("\x1b[36m");
expect(Bun.stripANSI(rendered)).toBe("[····]");
});
});