Export template source from 4c88728f144add3457b4273d4b9a04ee53c53be3:quixos-instance/packages/web-studio-canvas-runtime
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
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/,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user