UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

37 lines (36 loc) 1.03 kB
import { describe, expect, it } from "vitest"; import { getRouteInfoFromState } from "./getRouteInfo.mjs"; describe("getRouteInfoFromState", () => { const state = { routes: [{ name: "dev", path: "/dev#stack", params: { "#": "stack" } }] }; it("drops the hash from pathname and segments", () => { const info = getRouteInfoFromState((_state, asPath) => ({ path: asPath ? "/(site)/dev#stack" : "/dev#stack", params: { "#": "stack" } }), state); expect(info.pathname).toBe("/dev"); expect(info.segments).toEqual(["(site)", "dev"]); expect(info.unstable_globalHref).toBe("/dev#stack"); }); it("drops the query and the hash together", () => { const info = getRouteInfoFromState(() => ({ path: "/dev?x=1#stack", params: { x: "1", "#": "stack" } }), state); expect(info.pathname).toBe("/dev"); expect(info.segments).toEqual(["dev"]); }); }); //# sourceMappingURL=getRouteInfo.test.mjs.map