UNPKG

one

Version:

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

92 lines 4.59 kB
var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); var import_node_path = __toESM(require("node:path"), 1); var import_vitest = require("vitest"); var import_routeFileWatch = require("./routeFileWatch.cjs"); (0, import_vitest.describe)(import_routeFileWatch.isRouteFilePath, () => { (0, import_vitest.it)("matches route source files", () => { (0, import_vitest.expect)((0, import_routeFileWatch.isRouteFilePath)("/project/app/index.ts")).toBe(true); (0, import_vitest.expect)((0, import_routeFileWatch.isRouteFilePath)("/project/app/index.tsx")).toBe(true); (0, import_vitest.expect)((0, import_routeFileWatch.isRouteFilePath)("/project/app/index.js")).toBe(true); (0, import_vitest.expect)((0, import_routeFileWatch.isRouteFilePath)("/project/app/index.jsx")).toBe(true); }); (0, import_vitest.it)("ignores non-route files", () => { (0, import_vitest.expect)((0, import_routeFileWatch.isRouteFilePath)("/project/app/tamagui.generated.css")).toBe(false); (0, import_vitest.expect)((0, import_routeFileWatch.isRouteFilePath)("/project/app/routes.d.ts")).toBe(false); }); }); (0, import_vitest.describe)(import_routeFileWatch.isPathInsideDirectory, () => { (0, import_vitest.it)("only matches real descendants of the router root", () => { const routerRoot = import_node_path.default.resolve("/project/app"); (0, import_vitest.expect)((0, import_routeFileWatch.isPathInsideDirectory)("/project/app/index.tsx", routerRoot)).toBe(true); (0, import_vitest.expect)((0, import_routeFileWatch.isPathInsideDirectory)("/project/app-copy/index.tsx", routerRoot)).toBe(false); (0, import_vitest.expect)((0, import_routeFileWatch.isPathInsideDirectory)("/project/app", routerRoot)).toBe(false); }); }); (0, import_vitest.describe)(import_routeFileWatch.isRouteFileWatchEvent, () => { const routerRoot = import_node_path.default.resolve("/project/app"); (0, import_vitest.it)("matches route file add and delete events", () => { (0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({ event: "add", filePath: "/project/app/index.tsx", routerRoot })).toBe(true); (0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({ event: "delete", filePath: "/project/app/nested/page.jsx", routerRoot })).toBe(true); (0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({ event: "unlink", filePath: "/project/app/nested/page.jsx", routerRoot })).toBe(true); }); (0, import_vitest.it)("ignores non-route file add and delete events", () => { (0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({ event: "add", filePath: "/project/app/tamagui.generated.css", routerRoot })).toBe(false); (0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({ event: "delete", filePath: "/project/app/routes.d.ts", routerRoot })).toBe(false); }); (0, import_vitest.it)("only matches change events when requested", () => { (0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({ event: "change", filePath: "/project/app/index.tsx", routerRoot })).toBe(false); (0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({ event: "change", filePath: "/project/app/index.tsx", routerRoot, includeChangeEvents: true })).toBe(true); }); });