mirror of
https://github.com/cloudflare/vinext.git
synced 2026-09-14 19:04:59 +08:00
c17d6941be
* chore: migrate to vite plus
* Disable typeAware and typeCheck
* Update CI
* Fix CI
* Fix test
* Clean
* Run test with vp
* Try revert
* react: false In test
* Fix test
* Revert "Try revert"
This reverts commit 009da10473.
* Update
* Update
* Try revert ci changes
* revert
* Run vp migrate
* Disable typeAware and typeCheck for now
* Better resolve for test
* Use vp dev instead of vite
* Update expect
* Fix NormalizeManifestModuleId
* Try increase timeout
* Update to use vp
* Try new check
* Bring back npx vp
* Migrate CI
* Make next-intl resolvable
* Update
* Update
* Update
45 lines
1.8 KiB
TypeScript
45 lines
1.8 KiB
TypeScript
import { describe, expect, it } from "vite-plus/test";
|
|
import {
|
|
createValidFileMatcher,
|
|
normalizePageExtensions,
|
|
} from "../packages/vinext/src/routing/file-matcher.js";
|
|
|
|
describe("file matcher", () => {
|
|
it("normalizes pageExtensions with defaults and preserves configured values", () => {
|
|
expect(normalizePageExtensions()).toEqual(["tsx", "ts", "jsx", "js"]);
|
|
expect(normalizePageExtensions([])).toEqual(["tsx", "ts", "jsx", "js"]);
|
|
expect(normalizePageExtensions([".tsx", " ts ", "tsx", "", ".mdx"])).toEqual([
|
|
"tsx",
|
|
"ts",
|
|
"tsx",
|
|
"mdx",
|
|
]);
|
|
});
|
|
|
|
it("matches app router page and route files by configured extensions", () => {
|
|
// Ported from Next.js matcher tests:
|
|
// test/unit/find-page-file.test.ts
|
|
// https://github.com/vercel/next.js/blob/canary/test/unit/find-page-file.test.ts
|
|
const matcher = createValidFileMatcher(["tsx", "ts", "jsx", "js", "mdx"]);
|
|
|
|
expect(matcher.isAppRouterPage("page.js")).toBe(true);
|
|
expect(matcher.isAppRouterPage("./page.mdx")).toBe(true);
|
|
expect(matcher.isAppRouterPage("/path/page.tsx")).toBe(true);
|
|
expect(matcher.isAppRouterPage("/path/route.ts")).toBe(true);
|
|
|
|
expect(matcher.isAppRouterRoute("/path/route.ts")).toBe(true);
|
|
expect(matcher.isAppRouterRoute("/path/page.tsx")).toBe(false);
|
|
|
|
expect(matcher.isAppLayoutFile("/path/layout.tsx")).toBe(true);
|
|
expect(matcher.isAppDefaultFile("/path/default.mdx")).toBe(true);
|
|
expect(matcher.isAppRouterPage("/path/layout.tsx")).toBe(false);
|
|
});
|
|
|
|
it("strips configured extensions from file paths", () => {
|
|
const matcher = createValidFileMatcher(["js", "jsx", "mdx", "m+d"]);
|
|
expect(matcher.stripExtension("about.mdx")).toBe("about");
|
|
expect(matcher.stripExtension("index.m+d")).toBe("index");
|
|
expect(matcher.stripExtension("about.tsx")).toBe("about.tsx");
|
|
});
|
|
});
|