Skip to content

Commit d9cd1e7

Browse files
committed
add test for service binding fetch
1 parent 664f619 commit d9cd1e7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/miniflare/test/plugins/core/proxy/client.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,28 @@ describe("ProxyClient", () => {
5757
expect(event.data).toBe("echo:hello");
5858
});
5959

60+
test("preserves original URL for service binding fetch", async ({
61+
expect,
62+
}) => {
63+
const mf = new Miniflare({
64+
script: nullScript,
65+
serviceBindings: {
66+
CUSTOM(request: Request) {
67+
return new Response(request.url);
68+
},
69+
},
70+
});
71+
useDispose(mf);
72+
73+
const { CUSTOM } = await mf.getBindings<{
74+
CUSTOM: ReplaceWorkersTypes<Fetcher>;
75+
}>();
76+
77+
const url = "https://placeholder/path?query=value";
78+
const res = await CUSTOM.fetch(url);
79+
expect(await res.text()).toBe(url);
80+
});
81+
6082
test("supports serialising multiple ReadableStreams, Blobs and Files", async ({
6183
expect,
6284
}) => {

0 commit comments

Comments
 (0)