Skip to content

Commit

Permalink
test: introduce a separate test for #11629
Browse files Browse the repository at this point in the history
as suggested in review.
Reverts 1ce31c4.
  • Loading branch information
mspiess committed Jun 16, 2024
1 parent 3e29dec commit b3cf553
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions packages/react-router/__tests__/useResolvedPath-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,12 @@ describe("useResolvedPath", () => {
{
routes: (
<Route path="foo">
<Route>
<Route
path="*"
element={
<Component desc='<Route path="/foo"><Route path="*" />' />
}
/>
</Route>
<Route
path="*"
element={
<Component desc='<Route path="/foo"><Route path="*" />' />
}
/>
</Route>
),
},
Expand Down Expand Up @@ -422,6 +420,38 @@ describe("useResolvedPath", () => {
</div>"
`);
});

// gh-issue #11629
it("when enabled, '.' resolves to the current path including any splat paths nested in pathless routes", () => {
let { container } = render(
<MemoryRouter
initialEntries={["/foo/bar"]}
future={{ v7_relativeSplatPath: true }}
>
<Routes>
<Route path="foo">
<Route>
<Route path="*" element={<Component desc='<Route path="/foo"><Route><Route path="*" /></Route></Route>'/>}/>
</Route>
</Route>
</Routes>
</MemoryRouter>
);
let html = getHtml(container);
html = html ? html.replace(/&lt;/g, "<").replace(/&gt;/g, ">") : html;
expect(html).toMatchInlineSnapshot(`
"<div>
--- Routes: <Route path="/foo"><Route><Route path="*" /></Route></Route> ---
useLocation(): /foo/bar
useResolvedPath('.'): /foo/bar
useResolvedPath('..'): /foo
useResolvedPath('..', { relative: 'path' }): /foo
useResolvedPath('baz/qux'): /foo/bar/baz/qux
useResolvedPath('./baz/qux'): /foo/bar/baz/qux
</div>"
`);
});
});
});

Expand Down

0 comments on commit b3cf553

Please sign in to comment.