Files
oh-my-pi/packages/coding-agent/test/slash-command-format.test.ts
T
can1357 dca24b61b1 feat(coding-agent): added shimmer animations to loader and progress bars
- Added a new shimmerText helper that computes a moving accent shimmer band across characters.
- Updated the interactive mode loader and slash-command ASCII bar renderer to use shimmer styling, with interrupt hints kept dim.
- Added tests for shimmer-enabled progress rendering and verified the visible bar output remains correct.
2026-05-21 15:47:45 +09:00

41 lines
1.1 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`;
},
};
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("[····]");
});
});