testPackageReferences
tcmts.cli.flight.testPackageReferences · #vfwe246d · term
import { packageReferences } from "#codebase/tcmts/cli/flight";
export const testPackageReferences = () => {
const source = [
`import { Button, Link as L, mergeProps } from "npm__react-aria-components__1";`,
`import Dialog from "npm__thing__2/dialog";`,
`export const C = () => [Button, L, mergeProps, Dialog];`,
].join("\n");
const out = packageReferences(
source,
[
"npm:react-aria-components@1#Button",
"npm:react-aria-components@1#Link",
"npm:thing@2/dialog#default",
],
"file:///cache/tcm-flight.js",
);
for (const want of [
`const Button = __tcm_clientReference("npm:react-aria-components@1#Button", "c", []);`,
`const L = __tcm_clientReference("npm:react-aria-components@1#Link", "c", []);`,
`const Dialog = __tcm_clientReference("npm:thing@2/dialog#default", "c", []);`,
`import { mergeProps } from "npm__react-aria-components__1";`,
])
if (!out.includes(want)) throw new Error(`missing ${want}:\n${out}`);
if (out.includes(`from "npm__thing__2/dialog"`)) throw new Error(out);
}
uses