UNPKG

one

Version:

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

113 lines 2.87 kB
var import_vitest = require("vitest"), import_getPathFromState = require("./getPathFromState.cjs"); (0, import_vitest.describe)("hash support", () => { (0, import_vitest.it)("appends hash to the path", () => { (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)({ index: 0, key: "key", routes: [{ name: "index", path: "/", params: { "#": "hash1" } }], stale: !0, type: "stack" }, { screens: { index: "", _sitemap: "_sitemap" } })).toBe("/#hash1"); }), (0, import_vitest.it)("works with nested state, existing router and path params", () => { (0, import_vitest.expect)((0, import_getPathFromState.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"); }); }); import_vitest.it.skip("handles url search params params", () => { (0, import_vitest.expect)((0, import_getPathFromState.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"); }); (0, import_vitest.it)("handles uninitialized state on nested navigation with route params", () => { (0, import_vitest.expect)((0, import_getPathFromState.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"); });