Skip to content

Commit

Permalink
test: move to e2e test as flatRoutesUniversal wants only route files
Browse files Browse the repository at this point in the history
Signed-off-by: Logan McAnsh <logan@mcan.sh>
  • Loading branch information
mcansh committed Mar 14, 2023
1 parent 265d6ec commit b6f8725
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 17 deletions.
42 changes: 42 additions & 0 deletions integration/flat-routes-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,45 @@ test.describe("emits warnings for route conflicts", async () => {
expect(buildOutput).toContain(`⚠️ Route Path Collision: "/"`);
});
});

test.describe("", () => {
let buildStdio = new PassThrough();
let buildOutput: string;

let originalConsoleLog = console.log;
let originalConsoleWarn = console.warn;
let originalConsoleError = console.error;

test.beforeAll(async () => {
console.log = () => {};
console.warn = () => {};
console.error = () => {};
await createFixtureProject({
buildStdio,
future: { v2_routeConvention: true },
files: {
"app/routes/_index/route.jsx": js``,
"app/routes/_index/utils.js": js``,
},
});

let chunks: Buffer[] = [];
buildOutput = await new Promise<string>((resolve, reject) => {
buildStdio.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
buildStdio.on("error", (err) => reject(err));
buildStdio.on("end", () =>
resolve(Buffer.concat(chunks).toString("utf8"))
);
});
});

test.afterAll(() => {
console.log = originalConsoleLog;
console.warn = originalConsoleWarn;
console.error = originalConsoleError;
});

test("doesn't emit a warning for nested index files with co-located files", () => {
expect(buildOutput).not.toContain(`Route Path Collision`);
});
});
17 changes: 0 additions & 17 deletions packages/remix-dev/__tests__/flat-routes-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,23 +671,6 @@ describe("flatRoutes", () => {
);
});

test("nested index files", () => {
let testFiles = [
path.join("routes", "_index", "index.tsx"),
path.join("routes", "_index", "utils.ts"),
];

// route manifest uses the full path
let fullPaths = testFiles.map((file) => path.join(APP_DIR, file));

let routeManifest = flatRoutesUniversal(APP_DIR, fullPaths);

let routes = Object.values(routeManifest);

expect(routes).toHaveLength(1);
expect(consoleError).not.toHaveBeenCalled();
});

test("folder/route.tsx matching folder.tsx", () => {
let testFiles = [
path.join("routes", "dashboard", "route.tsx"),
Expand Down

0 comments on commit b6f8725

Please sign in to comment.