UNPKG

one

Version:

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

26 lines (24 loc) 1.58 kB
"use strict"; var import_vitest = require("vitest"); var import_router = require("./router.native.js"); var contextKey = "/account"; (0, import_vitest.afterEach)(function () { (0, import_router.unregisterProtectedRoutes)(contextKey); }); (0, import_vitest.describe)("protected route redirects", function () { (0, import_vitest.it)("resolves a protected href to its redirect target", function () { (0, import_router.registerProtectedRoutes)(contextKey, /* @__PURE__ */new Map([["settings", "/login"]])); (0, import_vitest.expect)((0, import_router.isRouteProtected)("/account/settings?tab=billing")).toBe(true); (0, import_vitest.expect)((0, import_router.resolveProtectedHref)("/account/settings?tab=billing")).toBe("/login"); }); (0, import_vitest.it)("blocks a protected href without an explicit target", function () { (0, import_router.registerProtectedRoutes)(contextKey, /* @__PURE__ */new Map([["settings", void 0]])); (0, import_vitest.expect)((0, import_router.resolveProtectedHref)("/account/settings")).toBeUndefined(); }); (0, import_vitest.it)("leaves allowed and similarly prefixed routes unchanged", function () { (0, import_router.registerProtectedRoutes)(contextKey, /* @__PURE__ */new Map([["settings", "/login"]])); (0, import_vitest.expect)((0, import_router.resolveProtectedHref)("/account/profile")).toBe("/account/profile"); (0, import_vitest.expect)((0, import_router.resolveProtectedHref)("/accounting/settings")).toBe("/accounting/settings"); }); }); //# sourceMappingURL=protectedRoutes.test.native.js.map