penpot/mcp/packages/plugin/src/ExecuteCodeTaskConsole.test.ts
Alonso Torres 286a6d5c9a
✨ Add new dashboard methods to the API (#12169)
* ✨ Add new dashboard methods to the API

* 🐛 Fix some issues with the new methods

* 🐛 Fix problem with mcp test
2026-10-14 15:24:53 +02:00

24 lines
971 B
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { ExecuteCodeTaskConsole } from "./ExecuteCodeTaskConsole.ts";
test("formats plain objects and primitives", () => {
const console = new ExecuteCodeTaskConsole();
console.log({ a: 1 }, null, "text", 42, undefined);
assert.equal(console.getLog(), '[LOG] {\n "a": 1\n} null text 42 undefined\n');
});
test("keeps the name and message of a logged error", () => {
const console = new ExecuteCodeTaskConsole();
console.error("failed", new TypeError("shape is undefined"));
assert.equal(console.getLog(), "[ERROR] failed TypeError: shape is undefined\n");
});
test("does not throw for values JSON cannot serialize", () => {
const console = new ExecuteCodeTaskConsole();
const circular: { self?: unknown } = {};
circular.self = circular;
console.log(circular, { big: 1n });
assert.equal(console.getLog(), "[LOG] [object Object] [object Object]\n");
});