Skip to content

Commit 7a9aeb7

Browse files
committed
revert _resetModuleScope and update test imports
1 parent 617b77c commit 7a9aeb7

File tree

14 files changed

+47
-38
lines changed

14 files changed

+47
-38
lines changed

packages/react-router-dom/__tests__/DataBrowserRouter-test.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ import {
2828
useSubmit,
2929
useFetcher,
3030
useFetchers,
31-
UNSAFE_resetModuleScope,
3231
UNSAFE_DataRouterStateContext,
33-
} from "../index";
32+
} from "react-router-dom";
33+
34+
// Private API
35+
import { _resetModuleScope } from "../../react-router/lib/components";
3436

3537
testDomRouter("<DataBrowserRouter>", DataBrowserRouter, (url) =>
3638
getWindowImpl(url, false)
@@ -40,7 +42,11 @@ testDomRouter("<DataHashRouter>", DataHashRouter, (url) =>
4042
getWindowImpl(url, true)
4143
);
4244

43-
function testDomRouter(name, TestDataRouter, getWindow) {
45+
function testDomRouter(
46+
name: string,
47+
TestDataRouter: typeof DataBrowserRouter,
48+
getWindow: (initialUrl: string, isHash?: boolean) => Window
49+
) {
4450
describe(name, () => {
4551
let consoleWarn: jest.SpyInstance;
4652
let consoleError: jest.SpyInstance;
@@ -52,7 +58,7 @@ function testDomRouter(name, TestDataRouter, getWindow) {
5258
afterEach(() => {
5359
consoleWarn.mockRestore();
5460
consoleError.mockRestore();
55-
UNSAFE_resetModuleScope();
61+
_resetModuleScope();
5662
});
5763

5864
it("renders the first route that matches the URL", () => {

packages/react-router-dom/__tests__/data-static-router-test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import * as React from "react";
22
import * as ReactDOMServer from "react-dom/server";
33
import {
4-
Route,
54
Outlet,
5+
Route,
66
useLoaderData,
77
useLocation,
88
useMatches,
9-
} from "../index";
10-
import { DataStaticRouter } from "../server";
9+
} from "react-router-dom";
10+
import { DataStaticRouter } from "react-router-dom/server";
1111

1212
beforeEach(() => {
1313
jest.spyOn(console, "warn").mockImplementation(() => {});

packages/react-router-dom/__tests__/nav-link-active-test.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ import {
1414
NavLink,
1515
Outlet,
1616
DataBrowserRouter,
17-
UNSAFE_resetModuleScope,
1817
} from "../index";
1918

19+
// Private API
20+
import { _resetModuleScope } from "../../react-router/lib/components";
21+
2022
describe("NavLink", () => {
2123
describe("when it does not match", () => {
2224
it("does not apply an 'active' className to the underlying <a>", () => {
@@ -327,7 +329,7 @@ describe("NavLink", () => {
327329

328330
describe("NavLink using a data router", () => {
329331
afterEach(() => {
330-
UNSAFE_resetModuleScope();
332+
_resetModuleScope();
331333
});
332334

333335
it("applies the default 'active'/'pending' classNames to the underlying <a>", async () => {

packages/react-router-dom/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ export {
153153
UNSAFE_RouteContext,
154154
UNSAFE_DataRouterContext,
155155
UNSAFE_DataRouterStateContext,
156-
UNSAFE_resetModuleScope,
157156
useRenderDataRouter,
158157
} from "react-router";
159158
//#endregion

packages/react-router-native/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ export {
117117
UNSAFE_RouteContext,
118118
UNSAFE_DataRouterContext,
119119
UNSAFE_DataRouterStateContext,
120-
UNSAFE_resetModuleScope,
121120
useRenderDataRouter,
122121
} from "react-router";
123122

packages/react-router/__tests__/DataMemoryRouter-test.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import "@testing-library/jest-dom";
1111
import type { FormMethod, Router } from "@remix-run/router";
1212
import { createMemoryRouter } from "@remix-run/router";
1313

14-
import type { DataMemoryRouterProps } from "../index";
14+
import type { DataMemoryRouterProps } from "react-router";
1515
import {
1616
DataMemoryRouter,
1717
MemoryRouter,
@@ -27,8 +27,10 @@ import {
2727
useRenderDataRouter,
2828
useRevalidator,
2929
UNSAFE_DataRouterContext,
30-
UNSAFE_resetModuleScope,
31-
} from "../index";
30+
} from "react-router";
31+
32+
// Private API
33+
import { _resetModuleScope } from "../lib/components";
3234

3335
describe("<DataMemoryRouter>", () => {
3436
let consoleWarn: jest.SpyInstance;
@@ -41,7 +43,7 @@ describe("<DataMemoryRouter>", () => {
4143
afterEach(() => {
4244
consoleWarn.mockRestore();
4345
consoleError.mockRestore();
44-
UNSAFE_resetModuleScope();
46+
_resetModuleScope();
4547
});
4648

4749
it("renders the first route that matches the URL", () => {

packages/react-router/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ import {
5353
Router,
5454
Routes,
5555
useRenderDataRouter,
56-
_resetModuleScope,
5756
} from "./lib/components";
5857
import type { Navigator, NavigateOptions } from "./lib/context";
5958
import {
@@ -186,6 +185,5 @@ export {
186185
RouteContext as UNSAFE_RouteContext,
187186
DataRouterContext as UNSAFE_DataRouterContext,
188187
DataRouterStateContext as UNSAFE_DataRouterStateContext,
189-
_resetModuleScope as UNSAFE_resetModuleScope,
190188
useRenderDataRouter,
191189
};

packages/router/__tests__/browser-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import { JSDOM } from "jsdom";
66

7-
import type { BrowserHistory } from "../history";
8-
import { createBrowserHistory } from "../history";
7+
import type { BrowserHistory } from "@remix-run/router";
8+
import { createBrowserHistory } from "@remix-run/router";
99

1010
import InitialLocationDefaultKey from "./TestSequences/InitialLocationDefaultKey";
1111
import Listen from "./TestSequences/Listen";

packages/router/__tests__/create-path-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createPath } from "../history";
1+
import { createPath } from "@remix-run/router";
22

33
describe("createPath", () => {
44
describe("given only a pathname", () => {

packages/router/__tests__/hash-base-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import { JSDOM } from "jsdom";
66

7-
import type { HashHistory } from "../history";
8-
import { createHashHistory } from "../history";
7+
import type { HashHistory } from "@remix-run/router";
8+
import { createHashHistory } from "@remix-run/router";
99

1010
describe("a hash history on a page with a <base> tag", () => {
1111
let history: HashHistory;

0 commit comments

Comments
 (0)