UNPKG

one

Version:

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

51 lines (50 loc) 1.74 kB
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "fs"; import { tmpdir } from "os"; import { dirname, join } from "path"; import { afterEach, describe, expect, it } from "vitest"; import { getManifest } from "./getManifest.native.js"; var testDir; function writeRoute(relativePath) { if (!testDir) { testDir = mkdtempSync(join(tmpdir(), "one-get-manifest-")); } var filePath = join(testDir, "app", relativePath); mkdirSync(dirname(filePath), { recursive: true }); writeFileSync(filePath, "export default function Route() { return null }"); } afterEach(function () { if (testDir) { rmSync(testDir, { recursive: true, force: true }); testDir = void 0; } }); describe("getManifest", function () { it("filters ignoredRouteFiles from server route manifests", function () { var _ref; writeRoute("index.tsx"); writeRoute("about.tsx"); writeRoute("contact.test.tsx"); writeRoute("admin/dashboard.tsx"); writeRoute("admin/types.ts"); writeRoute("api/users+api.ts"); var manifest = getManifest({ routerRoot: join(testDir, "app"), ignoredRouteFiles: ["**/*.test.*", "**/types.ts"] }); var files = (_ref = manifest === null || manifest === void 0 ? void 0 : manifest.allRoutes.map(function (route) { return route.file; })) !== null && _ref !== void 0 ? _ref : []; expect(files).toContain("./index.tsx"); expect(files).toContain("./about.tsx"); expect(files).toContain("./admin/dashboard.tsx"); expect(files).toContain("./api/users+api.ts"); expect(files).not.toContain("./contact.test.tsx"); expect(files).not.toContain("./admin/types.ts"); }); }); //# sourceMappingURL=getManifest.test.native.js.map