release: WRNexusJS 0.8.0
This commit is contained in:
@@ -25,6 +25,8 @@ test("generateRoutesFile emits a Routes map with param types", () => {
|
||||
expect(code).toContain('"/users/[id]": { "id": string };');
|
||||
expect(code).toContain('"/docs/[[...slug]]": { "slug"?: string | readonly string[] };');
|
||||
expect(code).toContain("export function href");
|
||||
expect(code).toContain('"users.id": "/users/[id]";');
|
||||
expect(code).toContain("export function route");
|
||||
});
|
||||
|
||||
test("generated href() fills required, optional and catch-all params", async () => {
|
||||
@@ -45,6 +47,11 @@ test("generated href() fills required, optional and catch-all params", async ()
|
||||
writeFileSync(file, code);
|
||||
const mod = (await import(pathToFileURL(file).href)) as {
|
||||
href: (p: string, params?: Record<string, string | string[]>) => string;
|
||||
route: (
|
||||
name: string,
|
||||
params?: Record<string, string | string[]>,
|
||||
query?: Record<string, string | number | boolean>,
|
||||
) => string;
|
||||
};
|
||||
expect(mod.href("/")).toBe("/");
|
||||
expect(mod.href("/users/[id]", { id: "42" })).toBe("/users/42");
|
||||
@@ -56,6 +63,9 @@ test("generated href() fills required, optional and catch-all params", async ()
|
||||
expect(mod.href("/docs/[...slug]", { slug: ["guide", "start here"] })).toBe(
|
||||
"/docs/guide/start%20here",
|
||||
);
|
||||
expect(mod.route("users.id", { id: "42" }, { tab: "profile", compact: true })).toBe(
|
||||
"/users/42?tab=profile&compact=true",
|
||||
);
|
||||
});
|
||||
|
||||
test("matches optional and catch-all routes", () => {
|
||||
|
||||
Reference in New Issue
Block a user