Skip to content

Commit

Permalink
I am sorry :(
Browse files Browse the repository at this point in the history
  • Loading branch information
Aareksio committed Nov 8, 2023
1 parent 7a8209b commit 51da5ba
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
readRawBody,
setCookie,
setResponseHeader,
getCookie,
sendRedirect,
} from "../src";
import { sendProxy, proxyRequest } from "../src/utils/proxy";

Expand Down Expand Up @@ -240,6 +242,40 @@ describe("", () => {

expect(resText).toEqual(message);
});

it("can proxy cookie on redirect", async () => {
app.use(
"/debug",
eventHandler((event) => {
setCookie(event, "cookie", "success");
return sendRedirect(event, "/2debug");
}),
);

app.use(
"/2debug",
eventHandler((event) => {
const cookieValue = getCookie(event, "cookie");
return cookieValue ?? "fail";
}),
);

app.use(
"/",
eventHandler((event) => {
return proxyRequest(event, url + "/debug", {
fetch,
});
}),
);

const result = await request.get("/");

expect(result.text).toEqual("success");

const cookies = result.header["set-cookie"];
expect(cookies).toEqual(["cookie=success; Path=/"]);
});
});

describe("multipleCookies", () => {
Expand Down

0 comments on commit 51da5ba

Please sign in to comment.