UNPKG

one

Version:

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

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