testAttestationsAreRead
tcmts.records.test.testAttestationsAreRead · #tf6kejuq · term
import { attestationRecord, parseAttestation } from "#codebase/tcmts/records";
export const testAttestationsAreRead = () => {
const at = {
subject: { namespace: "x", release: "geo@1.0.0", author: "did:plc:a" },
body: "Read it all.",
createdAt: "2026-11-03T00:00:00.000Z",
};
const r = parseAttestation("codes.tcm.review", at);
if (r?.kind !== "review" || r.subject.release !== "geo@1.0.0") throw new Error(JSON.stringify(r));
if (parseAttestation("codes.tcm.advisory", at)) throw new Error("an advisory has a severity");
const adv = parseAttestation("codes.tcm.advisory", { ...at, severity: "high", fixedIn: "1.0.1" });
if (adv?.severity !== "high" || adv.fixedIn !== "1.0.1") throw new Error(JSON.stringify(adv));
if (parseAttestation("codes.tcm.release", at)) throw new Error("not an attestation's collection");
if (parseAttestation("codes.tcm.yank", { ...at, subject: {} })) throw new Error("no subject");
const back = attestationRecord(adv);
if (
back.$type !== "codes.tcm.advisory" ||
JSON.stringify(parseAttestation("codes.tcm.advisory", back)) !== JSON.stringify(adv)
)
throw new Error(JSON.stringify(back));
}
uses