Skip to content

Commit a87b796

Browse files
Refactor lazy tests (#13383)
1 parent 9f07f81 commit a87b796

File tree

3 files changed

+522
-622
lines changed

3 files changed

+522
-622
lines changed

packages/react-router/__tests__/router/data-strategy-test.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
} from "../../lib/router/utils";
66
import {
77
createDeferred,
8-
createLazyStub,
8+
createAsyncStub,
99
setup,
1010
} from "./utils/data-router-setup";
1111
import { createFormData, tick } from "./utils/utils";
@@ -99,10 +99,8 @@ describe("router dataStrategy", () => {
9999
keyedResults(matches, results)
100100
)
101101
);
102-
let { lazyStub: lazyJsonStub, lazyDeferred: lazyJsonDeferred } =
103-
createLazyStub();
104-
let { lazyStub: lazyTextStub, lazyDeferred: lazyTextDeferred } =
105-
createLazyStub();
102+
let [lazyJson, lazyJsonDeferred] = createAsyncStub();
103+
let [lazyText, lazyTextDeferred] = createAsyncStub();
106104
let t = setup({
107105
routes: [
108106
{
@@ -111,12 +109,12 @@ describe("router dataStrategy", () => {
111109
{
112110
id: "json",
113111
path: "/test",
114-
lazy: lazyJsonStub,
112+
lazy: lazyJson,
115113
children: [
116114
{
117115
id: "text",
118116
index: true,
119-
lazy: lazyTextStub,
117+
lazy: lazyText,
120118
},
121119
],
122120
},
@@ -219,7 +217,7 @@ describe("router dataStrategy", () => {
219217
});
220218

221219
it("should allow custom implementations to override default behavior with lazy", async () => {
222-
let { lazyStub, lazyDeferred } = createLazyStub();
220+
let [lazy, lazyDeferred] = createAsyncStub();
223221
let t = setup({
224222
routes: [
225223
{
@@ -228,7 +226,7 @@ describe("router dataStrategy", () => {
228226
{
229227
id: "test",
230228
path: "/test",
231-
lazy: lazyStub,
229+
lazy,
232230
},
233231
],
234232
async dataStrategy({ matches }) {
@@ -374,7 +372,7 @@ describe("router dataStrategy", () => {
374372
});
375373

376374
it("does not require resolve to be called if a match is not being loaded", async () => {
377-
let { lazyStub, lazyDeferred } = createLazyStub();
375+
let [lazy, lazyDeferred] = createAsyncStub();
378376
let t = setup({
379377
routes: [
380378
{
@@ -389,7 +387,7 @@ describe("router dataStrategy", () => {
389387
{
390388
id: "child",
391389
path: "child",
392-
lazy: lazyStub,
390+
lazy,
393391
},
394392
],
395393
},
@@ -451,7 +449,7 @@ describe("router dataStrategy", () => {
451449
keyedResults(matches, results)
452450
);
453451
});
454-
let { lazyStub, lazyDeferred } = createLazyStub();
452+
let [lazy, lazyDeferred] = createAsyncStub();
455453
let t = setup({
456454
routes: [
457455
{
@@ -468,7 +466,7 @@ describe("router dataStrategy", () => {
468466
{
469467
id: "child",
470468
path: "child",
471-
lazy: lazyStub,
469+
lazy,
472470
},
473471
],
474472
},
@@ -632,7 +630,7 @@ describe("router dataStrategy", () => {
632630
keyedResults(matches, results)
633631
)
634632
);
635-
let { lazyStub, lazyDeferred } = createLazyStub();
633+
let [lazy, lazyDeferred] = createAsyncStub();
636634
let t = setup({
637635
routes: [
638636
{
@@ -641,7 +639,7 @@ describe("router dataStrategy", () => {
641639
{
642640
id: "json",
643641
path: "/test",
644-
lazy: lazyStub,
642+
lazy,
645643
},
646644
],
647645
dataStrategy,
@@ -721,7 +719,7 @@ describe("router dataStrategy", () => {
721719
keyedResults(matches, results)
722720
)
723721
);
724-
let { lazyStub, lazyDeferred } = createLazyStub();
722+
let [lazy, lazyDeferred] = createAsyncStub();
725723
let t = setup({
726724
routes: [
727725
{
@@ -730,7 +728,7 @@ describe("router dataStrategy", () => {
730728
{
731729
id: "json",
732730
path: "/test",
733-
lazy: lazyStub,
731+
lazy,
734732
},
735733
],
736734
dataStrategy,
@@ -808,7 +806,7 @@ describe("router dataStrategy", () => {
808806
keyedResults(matches, results)
809807
)
810808
);
811-
let { lazyStub, lazyDeferred } = createLazyStub();
809+
let [lazy, lazyDeferred] = createAsyncStub();
812810
let t = setup({
813811
routes: [
814812
{
@@ -817,7 +815,7 @@ describe("router dataStrategy", () => {
817815
{
818816
id: "json",
819817
path: "/test",
820-
lazy: lazyStub,
818+
lazy,
821819
},
822820
],
823821
dataStrategy,

0 commit comments

Comments
 (0)