aboutsummaryrefslogtreecommitdiff
path: root/test/js/web/html
diff options
context:
space:
mode:
Diffstat (limited to 'test/js/web/html')
-rw-r--r--test/js/web/html/FormData.test.ts19
-rw-r--r--test/js/web/html/URLSearchParams.test.ts5
2 files changed, 14 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");
diff --git a/test/js/web/html/URLSearchParams.test.ts b/test/js/web/html/URLSearchParams.test.ts
index 120bb2321..41c42c25d 100644
--- a/test/js/web/html/URLSearchParams.test.ts
+++ b/test/js/web/html/URLSearchParams.test.ts
@@ -7,15 +7,20 @@ describe("URLSearchParams", () => {
params.append("foo", "bar");
params.append("foo", "boop");
params.append("bar", "baz");
+ // @ts-ignore
expect(params.length).toBe(3);
params.delete("foo");
+ // @ts-ignore
expect(params.length).toBe(1);
params.append("foo", "bar");
+ // @ts-ignore
expect(params.length).toBe(2);
params.delete("foo");
params.delete("foo");
+ // @ts-ignore
expect(params.length).toBe(1);
params.delete("bar");
+ // @ts-ignore
expect(params.length).toBe(0);
});