Skip to content

Commit 36686ed

Browse files
committed
Update unit test to use mockServerBuild
1 parent 6f6f1c6 commit 36686ed

File tree

1 file changed

+18
-42
lines changed

1 file changed

+18
-42
lines changed

packages/react-router/__tests__/server-runtime/handle-error-test.ts

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { createRequestHandler } from "../../lib/server-runtime/server";
22
import { ErrorResponseImpl } from "../../lib/router/utils";
33
import { mockServerBuild } from "./utils";
4-
import type {
5-
HandleDocumentRequestFunction,
6-
ServerBuild,
7-
} from "../../lib/server-runtime/build";
4+
import type { HandleDocumentRequestFunction } from "../../lib/server-runtime/build";
85

96
function getHandler(
107
routeModule = {},
@@ -160,50 +157,29 @@ describe("handleError", () => {
160157
let error = new Error("💥");
161158

162159
let handleErrorSpy = jest.fn();
163-
let build: ServerBuild = {
164-
routes: {
165-
param: {
166-
id: "param",
167-
path: "/:param",
168-
module: {
169-
default() {
170-
return null;
171-
},
172-
loader() {
173-
throw error;
174-
},
160+
let build = mockServerBuild(
161+
{
162+
root: {
163+
path: "",
164+
default() {
165+
return null;
175166
},
176167
},
177-
},
178-
entry: {
179-
module: {
180-
handleError: handleErrorSpy,
168+
param: {
169+
path: ":param",
170+
parentId: "root",
181171
default() {
182-
return new Response("<html><body>Dummy document</body></html>");
172+
return null;
173+
},
174+
loader() {
175+
throw error;
183176
},
184177
},
185178
},
186-
routeDiscovery: {
187-
mode: "lazy",
188-
manifestPath: "/__manifest",
189-
},
190-
future: {
191-
// Fill in the required values
192-
unstable_middleware: false,
193-
unstable_subResourceIntegrity: false,
194-
},
195-
prerender: [],
196-
assets: {
197-
entry: { imports: [], module: "" },
198-
routes: {},
199-
url: "",
200-
version: "",
201-
},
202-
assetsBuildDirectory: "",
203-
publicPath: "/",
204-
ssr: true,
205-
isSpaMode: false,
206-
};
179+
{
180+
handleError: handleErrorSpy,
181+
}
182+
);
207183

208184
let handler = createRequestHandler(build);
209185
let request = new Request("http://example.com/a.data");

0 commit comments

Comments
 (0)