UNPKG

one

Version:

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

115 lines (114 loc) 2.65 kB
import { describe, expect, it } from "vitest"; import { getPathFromState } from "./getPathFromState.mjs"; describe("hash support", () => { it("appends hash to the path", () => { expect(getPathFromState({ index: 0, key: "key", routes: [{ name: "index", path: "/", params: { "#": "hash1" } }], stale: !0, type: "stack" }, { screens: { index: "", _sitemap: "_sitemap" } })).toBe("/#hash1"); }), it("works with nested state, existing router and path params", () => { expect(getPathFromState({ index: 1, key: "key", routeNames: ["index", "[test]", "_sitemap", "+not-found"], routes: [{ key: "key", name: "index", params: void 0, path: "/" }, { key: "key", name: "[test]", params: { test: "hello-world", query: "true", "#": "a" }, path: void 0 }], stale: !1, type: "stack" }, { screens: { "[test]": ":test", index: "", _sitemap: "_sitemap" } })).toBe("/hello-world?query=true#a"); }); }); it.skip("handles url search params params", () => { expect(getPathFromState({ routes: [{ name: "index", params: { test: "true", hello: "world", array: ["1", "2"] }, path: "/?test=true&hello=world&array=1&array=2" }] }, { screens: { index: "", _sitemap: "_sitemap" } })).toBe("/?test=true&hello=world&array=1&array=2"); }); it("handles uninitialized state on nested navigation with route params", () => { expect(getPathFromState({ routes: [{ name: "[folderSlugL1]", params: { folderSlugL1: "foo", screen: "[folderSlugL2]", params: { folderSlugL1: "foo", folderSlugL2: "bar", screen: "[folderSlugL3]", params: { folderSlugL1: "foo", folderSlugL2: "bar", folderSlugL3: "baz", screen: "page" } } } }] }, { screens: { index: "", "[folderSlugL1]": { path: ":folderSlugL1", screens: { "[folderSlugL2]": { path: ":folderSlugL2", screens: { "[folderSlugL3]": { path: ":folderSlugL3", screens: { page: "page" } } } } } } } })).toBe("/foo/bar/baz/page"); }); //# sourceMappingURL=getPathFromState.test.mjs.map