38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { decide, gateAfter, onRestart } from "../mod/ovis-composer/delivery.js";
|
|
|
|
test("decide idle/done -> send", () => {
|
|
assert.equal(decide("idle").kind, "send");
|
|
assert.equal(decide("done").kind, "send");
|
|
});
|
|
|
|
test("decide working -> queue, blocked -> hold", () => {
|
|
assert.equal(decide("working").kind, "queue");
|
|
assert.equal(decide("blocked").kind, "hold");
|
|
});
|
|
|
|
test("decide unknown status -> queue", () => {
|
|
assert.equal(decide("error").kind, "queue");
|
|
});
|
|
|
|
test("gateAfter needs a seen working turn", () => {
|
|
assert.equal(gateAfter("idle", false), false);
|
|
assert.equal(gateAfter("idle", true), true);
|
|
assert.equal(gateAfter("done", true), true);
|
|
assert.equal(gateAfter("working", true), false);
|
|
});
|
|
|
|
test("onRestart sending -> uncertain, others untouched", () => {
|
|
const out = onRestart([
|
|
{ id: "1", state: "sending" },
|
|
{ id: "2", state: "queued" },
|
|
{ id: "3", state: "held" },
|
|
]);
|
|
assert.deepEqual(out.map((i) => i.state), ["uncertain", "queued", "held"]);
|
|
});
|
|
|
|
test("onRestart tolerates non-array", () => {
|
|
assert.deepEqual(onRestart(null), []);
|
|
});
|