cb5bbbf382
- Eliminated core/ directory (252 files, 23 subdirs → distributed)
- Reduced max nesting from 9 levels to 5 levels
- Promoted tool subdirs to top level: exa/, lsp/, patch/, task/, web/
- Merged web-scrapers/ + web-search/ into web/{scrapers,search}/
- Flattened modes/interactive/ to modes/
- Split execution/ into: ipy/ (python), exec/ (bash), ssh/
- Renamed ipy/python-*.ts to ipy/*.ts (executor, kernel, etc.)
- Flattened cursor/exec-bridge.ts to cursor.ts
- Created logical groupings: config/, session/, extensibility/, export/
- Updated all imports across 500+ files
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import { type KernelDisplayOutput, PythonKernel } from "$c/ipy/kernel";
|
|
|
|
const renderDisplay = (
|
|
PythonKernel as unknown as {
|
|
prototype: {
|
|
renderDisplay: (content: Record<string, unknown>) => {
|
|
text: string;
|
|
outputs: KernelDisplayOutput[];
|
|
};
|
|
};
|
|
}
|
|
).prototype.renderDisplay;
|
|
|
|
describe("PythonKernel display rendering", () => {
|
|
it("normalizes text/plain output and returns no display outputs", () => {
|
|
const { text, outputs } = renderDisplay.call({} as PythonKernel, {
|
|
data: { "text/plain": "hello" },
|
|
});
|
|
|
|
expect(text).toBe("hello\n");
|
|
expect(outputs).toHaveLength(0);
|
|
});
|
|
|
|
it("collects image and json display outputs without text", () => {
|
|
const { text, outputs } = renderDisplay.call({} as PythonKernel, {
|
|
data: { "image/png": "abc", "application/json": { foo: "bar" } },
|
|
});
|
|
|
|
expect(text).toBe("");
|
|
expect(outputs).toEqual([
|
|
{ type: "image", data: "abc", mimeType: "image/png" },
|
|
{ type: "json", data: { foo: "bar" } },
|
|
]);
|
|
});
|
|
|
|
it("converts text/html to markdown", () => {
|
|
const { text, outputs } = renderDisplay.call({} as PythonKernel, {
|
|
data: { "text/html": "<p><strong>Hello</strong></p>" },
|
|
});
|
|
|
|
expect(outputs).toHaveLength(0);
|
|
expect(text).toBe("**Hello**\n");
|
|
});
|
|
|
|
it("combines text/plain with json output", () => {
|
|
const { text, outputs } = renderDisplay.call({} as PythonKernel, {
|
|
data: { "text/plain": "value", "application/json": { ok: true } },
|
|
});
|
|
|
|
expect(text).toBe("value\n");
|
|
expect(outputs).toEqual([{ type: "json", data: { ok: true } }]);
|
|
});
|
|
});
|