From 0412bb972d612e56564cb57c8dccda6dab960c3f Mon Sep 17 00:00:00 2001 From: jungwoo3490 Date: Tue, 7 May 2024 01:39:05 +0900 Subject: [PATCH] test: add unit test --- .../__tests__/static-location-test.tsx | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packages/react-router-dom/__tests__/static-location-test.tsx b/packages/react-router-dom/__tests__/static-location-test.tsx index 102e35da6e..016e80e6e1 100644 --- a/packages/react-router-dom/__tests__/static-location-test.tsx +++ b/packages/react-router-dom/__tests__/static-location-test.tsx @@ -56,5 +56,31 @@ describe("A ", () => { key: expect.any(String), }); }); + + it("retains a non-null state when passed explicitly", () => { + let location!: ReturnType; + function LocationChecker() { + location = useLocation(); + return null; + } + + ReactDOMServer.renderToStaticMarkup( + + + } /> + + + ); + + expect(location).toEqual({ + pathname: "/the/path", + search: "?the=query", + hash: "", + state: 0, + key: expect.any(String), + }); + }); }); });