Skip to content

Commit 19d5123

Browse files
fix: better structured tests with posix
1 parent 0398da0 commit 19d5123

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

packages/react-router-fs-routes/__tests__/flatRoutes-test.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -913,13 +913,26 @@ describe("flatRoutes", () => {
913913
});
914914
});
915915

916-
test("should include a valid file for a route outside of the app directory", () => {
917-
const routesDir = path.join("test", "root", "routes");
918-
const routeFile = path.join(routesDir, "route.tsx");
919-
920-
const manifest = flatRoutesUniversal(APP_DIR, [routeFile]);
921-
const routeInfo = manifest[path.relative(APP_DIR, routesDir)];
922-
expect(routeInfo).toBeDefined();
923-
expect(routeInfo.file).toBe(path.relative(APP_DIR, routeFile));
916+
describe("generates route manifest entry files relative to the app directory", () => {
917+
let testCases: [string, string][] = [
918+
[path.posix.join(APP_DIR, "routes"), "routes"],
919+
[
920+
path.posix.join(APP_DIR, "..", "routes"),
921+
path.posix.join("..", "routes"),
922+
],
923+
];
924+
925+
let fileName = "route.tsx";
926+
927+
testCases.forEach(([routesDir, expected]) => {
928+
test(`for routes directory "${routesDir}"`, () => {
929+
const routeFile = path.join(routesDir, fileName);
930+
const routeInfo = flatRoutesUniversal(APP_DIR, [routeFile]);
931+
const routes = Object.values(routeInfo);
932+
933+
expect(routes).toHaveLength(1);
934+
expect(routes[0].file).toBe(path.posix.join(expected, fileName));
935+
});
936+
});
924937
});
925938
});

0 commit comments

Comments
 (0)