UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

48 lines (45 loc) • 1.39 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) { id = id.replace(/^\.\//, "").replace(/\.\w*$/, ""); return typeof context[id] === "function" ? { default: context[id] } : context[id]; }, { resolve: function resolve(key) { return key; }, id: "0", keys: function keys() { return Object.keys(context).map(function(key) { var 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(function(filename) { return [filename, { default: function _default() { return null; } }]; }))); } throw new Error("Invalid context"); } function getMockConfig(context) { var metaOnly = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true; return getReactNavigationConfig(getRoutes(getMockContext(context)), metaOnly); } export { getMockConfig, getMockContext, inMemoryContext }; //# sourceMappingURL=testing-utils.native.js.map