testReleaseRecordsAreRead

tcmts.records.test.testReleaseRecordsAreRead · #jwlrqlq3 · term

import { parseReleaseRecord } from "#codebase/tcmts/records";

export const testReleaseRecordsAreRead = () => {
  const good = {
    $type: "codes.tcm.release",
    package: "geo",
    version: "1.2.0",
    namespace: "ofruor5lwehvlu7fm7ii6xja4lat2kwunkno4iqipf3holmwm2xq",
    entry: "y",
    hashFormat: 2,
    notes: "",
    sources: ["https://alice.dev", "file:///etc", 3],
    createdAt: "2026-11-03T00:00:00.000Z",
  };
  const r = parseReleaseRecord(good);
  if (JSON.stringify(r?.sources) !== '["https://alice.dev"]') throw new Error(JSON.stringify(r));
  if (parseReleaseRecord({ ...good, namespace: 1 })) throw new Error("a namespace that isn't text");
  if (parseReleaseRecord({ ...good, $type: "app.bsky.feed.post" }))
    throw new Error("another kind of record");
  if (parseReleaseRecord(null)) throw new Error("null");
}

uses