Skip to content

Commit

Permalink
add back headers tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jul 24, 2023
1 parent 9a57518 commit 1e115b6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
setHeader,
readRawBody,
setCookie,
setResponseHeader,
} from "../src";
import { sendProxy, proxyRequest } from "../src/utils/proxy";

Expand Down Expand Up @@ -114,6 +115,7 @@ describe("", () => {
eventHandler(async (event) => {
const body = await readRawBody(event, false);
return {
headers: getHeaders(event),
bytes: body!.length,
};
})
Expand All @@ -122,6 +124,7 @@ describe("", () => {
app.use(
"/",
eventHandler((event) => {
setResponseHeader(event, "x-res-header", "works");
return proxyRequest(event, url + "/debug", { fetch });
})
);
Expand All @@ -134,15 +137,14 @@ describe("", () => {
method: "POST",
body: dummyFile,
headers: {
"content-type": "text/custom",
"x-custom": "hello",
"x-req-header": "works",
},
});
const { bytes } = await res.json();
const resBody = await res.json();

// expect(res.headers.get("content-type")).toEqual("text/custom");
// expect(res.headers.get("x-custom")).toEqual("hello");
expect(bytes).toEqual(dummyFile.length);
expect(res.headers.get("x-res-header")).toEqual("works");
expect(resBody.headers["x-req-header"]).toEqual("works");
expect(resBody.bytes).toEqual(dummyFile.length);
});
});

Expand Down

0 comments on commit 1e115b6

Please sign in to comment.