Skip to content

Commit

Permalink
fix unit test and revert getRoutePath change
Browse files Browse the repository at this point in the history
  • Loading branch information
tylersayshi committed Dec 18, 2024
1 parent 0040ecd commit 5549e2e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
13 changes: 8 additions & 5 deletions packages/waku/src/router/create-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,15 @@ export const createPages = <

/** helper to find dynamic path when slugs are used */
const getRoutePath: (path: string) => string | undefined = (path) => {
const staticPathSpec = staticPathMap.get(path);
if (staticPathSpec) {
return pathSpecAsString(
staticPathSpec.originalSpec ?? staticPathSpec.literalSpec,
);
if (staticComponentMap.has(joinPath(path, 'page').slice(1))) {
return path;
}
// const staticPathSpec = staticPathMap.get(path);
// if (staticPathSpec) {
// return pathSpecAsString(
// staticPathSpec.originalSpec ?? staticPathSpec.literalSpec,
// );
// }
const allPaths = [
...dynamicPagePathMap.keys(),
...wildcardPagePathMap.keys(),
Expand Down
7 changes: 6 additions & 1 deletion packages/waku/tests/create-pages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ describe('createPages', () => {
elements: {
root: { isStatic: true },
'page:/test/nested': { isStatic: true },
'layout:/test/nested': { isStatic: true },
},
routeElement: { isStatic: true },
noSsr: false,
Expand All @@ -668,7 +669,11 @@ describe('createPages', () => {
});
expect(route).toBeDefined();
expect(route.routeElement).toBeDefined();
expect(Object.keys(route.elements)).toEqual(['root', 'page:/test/nested']);
expect(Object.keys(route.elements)).toEqual([
'root',
'page:/test/nested',
'layout:/test/nested',
]);
});

it('creates a nested dynamic page', async () => {
Expand Down

0 comments on commit 5549e2e

Please sign in to comment.