43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
import assert from "node:assert/strict";
|
|||
|
|
import test from "node:test";
|
||
|
|
import { normalizePlacementInput } from "../dist/canvas.impl.js";
|
||
|
|
import { protoValueToJs } from "@quixos/camino-package-runtime";
|
||
|
|
|
||
|
|
const reference = (objectId) => protoValueToJs({ kind: { case: "refValue", value: { objectId } } });
|
||
|
|
const canvas = reference("obj:canvas"),
|
||
|
|
subject = reference("obj:subject");
|
||
|
|
|
||
|
|
test("placement input is bounded and normalized", () => {
|
||
|
|
assert.deepEqual(
|
||
|
|
normalizePlacementInput({
|
||
|
|
canvas_id: canvas,
|
||
|
|
subject_id: subject,
|
||
|
|
x: 12.5,
|
||
|
|
y: -30,
|
||
|
|
width: 12,
|
||
|
|
height: 80,
|
||
|
|
z: 3.8,
|
||
|
|
}),
|
||
|
|
{
|
||
|
|
canvas_id: canvas,
|
||
|
|
subject_id: subject,
|
||
|
|
x: 12.5,
|
||
|
|
y: -30,
|
||
|
|
width: 220,
|
||
|
|
height: 150,
|
||
|
|
z: 3,
|
||
|
|
},
|
||
|
|
);
|
||
|
|
});
|
||
|
|
|
||
|
|
test("placement input requires Camino object references", () => {
|
||
|
|
assert.throws(
|
||
|
|
() => normalizePlacementInput({ canvas_id: "canvas", subject_id: "obj:subject" }),
|
||
|
|
/canvas_id must be a managed object reference/,
|
||
|
|
);
|
||
|
|
assert.throws(
|
||
|
|
() => normalizePlacementInput({ canvas_id: "obj:canvas", subject_id: subject }),
|
||
|
|
/managed object reference/,
|
||
|
|
);
|
||
|
|
});
|