aboutsummaryrefslogtreecommitdiff
path: root/test/js/web/html/FormData.test.ts
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-07-11 19:14:34 -0700
committerGravatar GitHub <noreply@github.com> 2023-07-11 19:14:34 -0700
commitcbb88672f217a90db1aa1eb29cd92d5d9035b22b (patch)
tree43a00501f3cde495967e116f0b660777051551f8 /test/js/web/html/FormData.test.ts
parent1f900cff453700b19bca2acadfe26da4468c1282 (diff)
parent34b0e7a2bbd8bf8097341cdb0075d0908283e834 (diff)
downloadbun-jarred/esm-conditions.tar.gz
bun-jarred/esm-conditions.tar.zst
bun-jarred/esm-conditions.zip
Merge branch 'main' into jarred/esm-conditionsjarred/esm-conditions
Diffstat (limited to '')
-rw-r--r--test/js/web/html/FormData.test.ts19
1 files changed, 9 insertions, 10 deletions
diff --git a/test/js/web/html/FormData.test.ts b/test/js/web/html/FormData.test.ts
index cbaf5aaa7..45b4f2f5a 100644
--- a/test/js/web/html/FormData.test.ts
+++ b/test/js/web/html/FormData.test.ts
@@ -301,17 +301,18 @@ describe("FormData", () => {
expect(await (body.get("foo") as Blob).text()).toBe("baz");
server.stop(true);
});
-
+ type FetchReqArgs = [request: Request, init?: RequestInit];
+ type FetchURLArgs = [url: string | URL | Request, init?: FetchRequestInit];
for (let useRequestConstructor of [true, false]) {
describe(useRequestConstructor ? "Request constructor" : "fetch()", () => {
- function send(args: Parameters<typeof fetch>) {
+ function send(args: FetchReqArgs | FetchURLArgs) {
if (useRequestConstructor) {
- return fetch(new Request(...args));
+ return fetch(new Request(...(args as FetchReqArgs)));
} else {
- return fetch(...args);
+ return fetch(...(args as FetchURLArgs));
}
}
- for (let headers of [{}, undefined, { headers: { X: "Y" } }]) {
+ for (let headers of [{} as {}, undefined, { headers: { X: "Y" } }]) {
describe("headers: " + Bun.inspect(headers).replaceAll(/([\n ])/gim, ""), () => {
it("send on HTTP server with FormData & Blob (roundtrip)", async () => {
let contentType = "";
@@ -330,11 +331,10 @@ describe("FormData", () => {
form.append("bar", "baz");
// @ts-ignore
- const reqBody = [
+ const reqBody: FetchURLArgs = [
`http://${server.hostname}:${server.port}`,
{
body: form,
-
headers,
method: "POST",
},
@@ -364,7 +364,6 @@ describe("FormData", () => {
form.append("foo", file);
form.append("bar", "baz");
- // @ts-ignore
const reqBody = [
`http://${server.hostname}:${server.port}`,
{
@@ -374,7 +373,7 @@ describe("FormData", () => {
method: "POST",
},
];
- const res = await send(reqBody);
+ const res = await send(reqBody as FetchURLArgs);
const body = await res.formData();
expect(await (body.get("foo") as Blob).text()).toBe(text);
expect(contentType).toContain("multipart/form-data");
@@ -410,7 +409,7 @@ describe("FormData", () => {
method: "POST",
},
];
- const res = await send(reqBody);
+ const res = await send(reqBody as FetchURLArgs);
const body = await res.formData();
expect(contentType).toContain("multipart/form-data");
expect(body.get("foo")).toBe("boop");