forked from remix-run/remix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: change how request is "cloned" for loaders (remix-run#3218)
* fix: change how request is "cloned" for loaders * removed derrived properties from init
- Loading branch information
1 parent
50b41e1
commit 8bdd2f8
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { json } from "../responses"; | ||
import { createRequestHandler } from "../server"; | ||
|
||
describe("createRequestHandler", () => { | ||
it("retains request headers when stripping body off for loaders", async () => { | ||
let handler = createRequestHandler({ | ||
routes: { | ||
root: { | ||
id: "routes/test", | ||
path: "/test", | ||
module: { | ||
loader: ({ request }) => json(request.headers.get("X-Foo")), | ||
} as any, | ||
}, | ||
}, | ||
assets: {} as any, | ||
entry: { module: {} as any }, | ||
}); | ||
|
||
let response = await handler( | ||
new Request("http://.../test", { | ||
headers: { | ||
"X-Foo": "bar", | ||
}, | ||
}) | ||
); | ||
|
||
expect(await response.json()).toBe("bar"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters