Files
oh-my-pi/packages/coding-agent/test/core/python-executor-display.test.ts
T
can1357 779ca4872b style(deps): migrated from Prettier to Biome and updated formatting rules
- Removed Prettier configuration files (.prettierignore and .prettierrc) and migrated formatting to Biome.
- Updated Biome configuration from version 2.3.11 to 2.3.12 and changed arrowParentheses rule from 'always' to 'asNeeded'.
- Pinned @biomejs/biome dependency to exact version 2.3.12 in package.json and bun.lock.
- Applied consistent arrow function formatting across 489 files by removing unnecessary parentheses around single parameters.
- Removed blank lines after comment blocks and reorganized imports for consistency across the codebase.
2026-01-24 04:20:19 +01:00

47 lines
1.4 KiB
TypeScript

import { describe, expect, it } from "bun:test";
import { executePythonWithKernel, type PythonKernelExecutor } from "@oh-my-pi/pi-coding-agent/ipy/executor";
import type {
KernelDisplayOutput,
KernelExecuteOptions,
KernelExecuteResult,
} from "@oh-my-pi/pi-coding-agent/ipy/kernel";
class FakeKernel implements PythonKernelExecutor {
private result: KernelExecuteResult;
private onExecute: (options?: KernelExecuteOptions) => Promise<void> | void;
constructor(result: KernelExecuteResult, onExecute: (options?: KernelExecuteOptions) => Promise<void> | void) {
this.result = result;
this.onExecute = onExecute;
}
async execute(_code: string, options?: KernelExecuteOptions): Promise<KernelExecuteResult> {
await this.onExecute(options);
return this.result;
}
}
describe("executePythonWithKernel display outputs", () => {
it("aggregates display outputs in order", async () => {
const outputs: KernelDisplayOutput[] = [
{ type: "json", data: { foo: "bar" } },
{ type: "image", data: "abc", mimeType: "image/png" },
];
const kernel = new FakeKernel(
{ status: "ok", cancelled: false, timedOut: false, stdinRequested: false },
async options => {
if (!options?.onDisplay) return;
for (const output of outputs) {
await options.onDisplay(output);
}
},
);
const result = await executePythonWithKernel(kernel, "print('hi')");
expect(result.exitCode).toBe(0);
expect(result.displayOutputs).toEqual(outputs);
});
});