import assert from "node:assert/strict"; import { renderMachineView } from "./machine-view.mjs"; class CanvasContext { constructor() { this.pixels = 0; } fillRect() { this.pixels += 1; } strokeRect() { this.pixels += 1; } beginPath() {} arc() {} fill() { this.pixels += 1; } moveTo() {} lineTo() {} stroke() { this.pixels += 1; } } class Node { constructor(tag) { this.tagName = tag; this.children = []; this.className = ""; this.textContent = ""; this.width = 0; this.height = 0; this.context = new CanvasContext(); } append(...nodes) { this.children.push(...nodes); } setAttribute() {} getContext() { return this.context; } } const document = { createElement: (tag) => new Node(tag) }; const view = renderMachineView(document, { pose: { x: 1, y: 2, z: 3 }, joints: [1, 2, 3], toolpath: [{ x: 0, y: 0 }, { x: 2, y: 2 }], stock: { width: 2 }, stateHash: "fnv1a64:machine" }); assert.equal(view.children[1].width, 640); assert.equal(view.children[1].height, 320); assert.ok(view.children[1].context.pixels > 0); assert.match(view.children[2].textContent, /joints 3/); console.log(`machine_view=passed pixels=${view.children[1].context.pixels} canvas=${view.children[1].width}x${view.children[1].height}`);