UNPKG

one

Version:

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

36 lines (35 loc) 1.22 kB
import path from "node:path"; import { getReactNavigationConfig } from "./getReactNavigationConfig.mjs"; import { getRoutes } from "./router/getRoutes.mjs"; const validExtensions = [".js", ".jsx", ".ts", ".tsx"]; function inMemoryContext(context) { return Object.assign(id => { id = id.replace(/^\.\//, "").replace(/\.\w*$/, ""); return typeof context[id] === "function" ? { default: context[id] } : context[id]; }, { resolve: key => key, id: "0", keys: () => Object.keys(context).map(key => { const ext = path.extname(key); key = key.replace(/^\.\//, ""); key = key.startsWith("/") ? key : `./${key}`; key = validExtensions.includes(ext) ? key : `${key}.js`; return key; }) }); } function getMockContext(context) { if (Array.isArray(context)) { return inMemoryContext(Object.fromEntries(context.map(filename => [filename, { default: () => null }]))); } throw new Error("Invalid context"); } function getMockConfig(context, metaOnly = true) { return getReactNavigationConfig(getRoutes(getMockContext(context)), metaOnly); } export { getMockConfig, getMockContext, inMemoryContext }; //# sourceMappingURL=testing-utils.mjs.map