// A service asking for its sign-up link describes itself in `target`; the backend // keeps only the short, plain values it can show the user who answers the link. // Run with `npm test` from the repository root, or `node --test tests/`. const { test } = require("node:test"); const assert = require("node:assert/strict"); const serviceLinks = require("../backend/src/services/service-links"); test("a link request keeps the service metadata short and plain", () => { const target = serviceLinks.readTarget({ target: { id: "world-1", name: "Test World", user: "Test GM", meta: { system: "dnd5e", url: "https://vtt.test/some/path", nested: { ignored: true }, long: "x".repeat(500), }, }, }); assert.equal(target.targetId, "world-1"); assert.equal(target.targetMeta.system, "dnd5e"); assert.equal(target.targetMeta.url, "https://vtt.test", "only the origin of the world URL is kept"); assert.equal(target.targetMeta.nested, undefined, "objects are not copied into the metadata"); assert.equal(target.targetMeta.long.length, 200, "long values are cut to the metadata limit"); });