import { expect, test } from "vitest"; import { createLocalizedRoute, createRoute } from "../routes/create.ts"; import type { EndRoute } from "../routes/interfaces.ts"; import { createRouter } from "./createRouter.ts"; const ref = Symbol("ref"); const route = createRoute("/", "/", ref); const localizedPathsRecord = { en: "/posts", fr: "/articles" }; const localizedRoute = createLocalizedRoute( localizedPathsRecord, localizedPathsRecord, ref, ); const router = createRouter( [route, localizedRoute], new Map>([ ["/", route], ["/blog", localizedRoute], ]), ); test("get by key should return route", () => { expect(router.get("/")).toBe(route); }); test("find should return route match", () => { const match = router.find("/"); expect(match?.routePath).toBe(route.path); }); test("toPath should return url", () => { expect(router.toPath("/")).toBe("/"); }); test("toLocalizedPath should return url", () => { expect(router.toLocalizedPath("fr", "/blog")).toBe("/articles"); });