Files
oh-my-pi/packages/coding-agent/test/tools/browser-display-format.test.ts
can1357 ff49b986d5 feat(coding-agent/tools): introduced language-specific code formatters for display rendering
- Added language-specific code formatters for JavaScript, Julia, Python, and Ruby to improve display rendering.
- Integrated display formatting into browser run and eval render tools while preserving verbatim execution.
- Added comprehensive test suites verifying formatting stability, lexical safety, and streaming behavior.
2026-07-24 16:26:03 +02:00

34 lines
1.2 KiB
TypeScript

import { afterAll, beforeAll, describe, expect, it } from "bun:test";
import { resetSettingsForTest, Settings } from "@oh-my-pi/pi-coding-agent/config/settings";
import { getThemeByName, setThemeInstance, type Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme";
import { toolRenderers } from "@oh-my-pi/pi-coding-agent/tools/renderers";
describe("browser renderer: display-only streaming formatting", () => {
let theme: Theme;
beforeAll(async () => {
resetSettingsForTest();
await Settings.init({ inMemory: true, cwd: process.cwd() });
theme = (await getThemeByName("dark"))!;
expect(theme).toBeDefined();
setThemeInstance(theme);
});
afterAll(() => {
resetSettingsForTest();
});
it("expands compact JavaScript without mutating the run source", () => {
const source = "if (ready) {run();finish();}";
const args = { action: "run", code: source };
const rendered = Bun.stripANSI(
toolRenderers.browser.renderCall(args, { expanded: true, isPartial: true }, theme).render(120).join("\n"),
);
expect(rendered).toContain("run();");
expect(rendered).toContain("finish();");
expect(rendered).not.toContain("run();finish();");
expect(args.code).toBe(source);
});
});