Skip to content

Commit

Permalink
test: add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jungwoo3490 committed May 6, 2024
1 parent 371044c commit 0412bb9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/react-router-dom/__tests__/static-location-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,31 @@ describe("A <StaticRouter>", () => {
key: expect.any(String),
});
});

it("retains a non-null state when passed explicitly", () => {
let location!: ReturnType<typeof useLocation>;
function LocationChecker() {
location = useLocation();
return null;
}

ReactDOMServer.renderToStaticMarkup(
<StaticRouter
location={{ pathname: "/the/path", search: "?the=query", state: 0 }}
>
<Routes>
<Route path="/the/path" element={<LocationChecker />} />
</Routes>
</StaticRouter>
);

expect(location).toEqual({
pathname: "/the/path",
search: "?the=query",
hash: "",
state: 0,
key: expect.any(String),
});
});
});
});

0 comments on commit 0412bb9

Please sign in to comment.