18 lines
1.1 KiB
JavaScript
18 lines
1.1 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { CommandController } from "./controls.mjs";
|
|
import { EMPTY_STATE, reduceWorkerState } from "./state-panel.mjs";
|
|
|
|
const calls = [];
|
|
const client = { send: async (kind, payload, options) => { calls.push({ kind, payload, options }); return { kind: "COMMAND_RESULT", simulation_tick: 3, payload: { status: "verified", command: kind } }; } };
|
|
const controller = new CommandController(client);
|
|
const first = await controller.execute("run", { program: "main.ngc" });
|
|
assert.equal(first.payload.command, "PROGRAM_RUN");
|
|
await controller.execute("estop", { active: true }, { operationId: "estop-fixed" });
|
|
assert.equal(calls[1].kind, "ESTOP");
|
|
assert.equal(calls[1].options.operationId, "estop-fixed");
|
|
assert.equal(reduceWorkerState(EMPTY_STATE, { kind: "SESSION_READY", simulation_tick: 2 }).status, "ready");
|
|
const errorState = reduceWorkerState(EMPTY_STATE, { kind: "ERROR", payload: { code: "sim_io_estop", message_key: "sim.estop" } });
|
|
assert.equal(errorState.status, "error");
|
|
assert.equal(errorState.error, "sim_io_estop");
|
|
console.log(`frontend_m2=passed commands=${calls.length}`);
|