testAnnouncedSpecs

tcmts.cli.libraries.test.testAnnouncedSpecs · #fg7adqho · term

import { announcedSpec } from "#codebase/tcmts/cli/libraries";

export const testAnnouncedSpecs = () => {
  const say = (s: string, w?: string) => JSON.stringify(announcedSpec(s, w));
  if (say("@alice.dev/geo@1.2.0") !== '{"who":"alice.dev","what":"geo@1.2.0"}')
    throw new Error(say("@alice.dev/geo@1.2.0"));
  if (say("@alice.dev", "geo") !== '{"who":"alice.dev","what":"geo"}')
    throw new Error(say("@alice.dev", "geo"));
  if (say("@did:plc:abc/@scope/geo") !== '{"who":"did:plc:abc","what":"@scope/geo"}')
    throw new Error(say("@did:plc:abc/@scope/geo"));
  if (say("@alice.dev") !== '{"who":"alice.dev"}') throw new Error(say("@alice.dev"));
  if (announcedSpec("https://alice.dev", "geo") !== undefined)
    throw new Error("a URL isn't announced");
}

uses