92ec2550d2
- Moved test files from src/core to test/core directory. - Moved test files from src/core/tools to test/tools directory. - Moved test files from src/discovery to test/discovery directory. - Updated import paths to reflect new test file locations.
37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import stripAnsi from "strip-ansi";
|
|
import { pythonToolRenderer } from "../../src/core/tools/python";
|
|
import { truncateTail } from "../../src/core/tools/truncate";
|
|
import { getThemeByName } from "../../src/modes/interactive/theme/theme";
|
|
|
|
describe("pythonToolRenderer", () => {
|
|
it("renders truncated output when collapsed and full output when expanded", () => {
|
|
const theme = getThemeByName("dark");
|
|
expect(theme).toBeDefined();
|
|
const uiTheme = theme!;
|
|
|
|
const fullOutput = ["line 1", "line 2", "line 3", "line 4"].join("\n");
|
|
const truncation = truncateTail(fullOutput, { maxLines: 2, maxBytes: 128 });
|
|
|
|
const result = {
|
|
content: [{ type: "text", text: truncation.content }],
|
|
details: {
|
|
truncation,
|
|
fullOutput,
|
|
},
|
|
};
|
|
|
|
const collapsed = pythonToolRenderer.renderResult(result, { expanded: false, isPartial: false }, uiTheme);
|
|
const collapsedLines = stripAnsi(collapsed.render(80).join("\n"));
|
|
expect(collapsedLines).toContain("line 4");
|
|
expect(collapsedLines).not.toContain("line 1");
|
|
expect(collapsedLines).toContain("Truncated:");
|
|
|
|
const expanded = pythonToolRenderer.renderResult(result, { expanded: true, isPartial: false }, uiTheme);
|
|
const expandedLines = stripAnsi(expanded.render(80).join("\n"));
|
|
expect(expandedLines).toContain("line 1");
|
|
expect(expandedLines).toContain("line 4");
|
|
expect(expandedLines).not.toContain("Truncated:");
|
|
});
|
|
});
|