From 689cbd7eb395f8f4e19b8111160022b34bee57b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 21 Aug 2023 18:42:12 +0200 Subject: [PATCH] refactor(remix-server-runtime): use native Fetch API --- .../__tests__/formData-test.ts | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/packages/remix-server-runtime/__tests__/formData-test.ts b/packages/remix-server-runtime/__tests__/formData-test.ts index 65299dc885f..7eb571017ff 100644 --- a/packages/remix-server-runtime/__tests__/formData-test.ts +++ b/packages/remix-server-runtime/__tests__/formData-test.ts @@ -1,7 +1,3 @@ -import { - Request as NodeRequest, - FormData as NodeFormData, -} from "@remix-run/web-fetch"; import { Blob, File } from "@remix-run/web-file"; import { parseMultipartFormData } from "../formData"; @@ -14,12 +10,12 @@ class CustomError extends Error { describe("parseMultipartFormData", () => { it("can use a custom upload handler", async () => { - let formData = new NodeFormData(); + let formData = new FormData(); formData.set("a", "value"); formData.set("blob", new Blob(["blob".repeat(1000)]), "blob.txt"); formData.set("file", new File(["file".repeat(1000)], "file.txt")); - let req = new NodeRequest("https://test.com", { + let req = new Request("https://test.com", { method: "post", body: formData, }); @@ -48,12 +44,12 @@ describe("parseMultipartFormData", () => { }); it("can return undefined", async () => { - let formData = new NodeFormData(); + let formData = new FormData(); formData.set("a", "value"); formData.set("blob", new Blob(["blob".repeat(1000)]), "blob.txt"); formData.set("file", new File(["file".repeat(1000)], "file.txt")); - let req = new NodeRequest("https://test.com", { + let req = new Request("https://test.com", { method: "post", body: formData, }); @@ -69,10 +65,10 @@ describe("parseMultipartFormData", () => { }); it("can throw errors in upload handlers", async () => { - let formData = new NodeFormData(); + let formData = new FormData(); formData.set("blob", new Blob(["blob"]), "blob.txt"); - let req = new NodeRequest("https://test.com", { + let req = new Request("https://test.com", { method: "post", body: formData, }); @@ -92,12 +88,12 @@ describe("parseMultipartFormData", () => { describe("stream should propagate events", () => { it("when controller errors", async () => { - let formData = new NodeFormData(); + let formData = new FormData(); formData.set("a", "value"); formData.set("blob", new Blob(["blob".repeat(1000)]), "blob.txt"); formData.set("file", new File(["file".repeat(1000)], "file.txt")); - let underlyingRequest = new NodeRequest("https://test.com", { + let underlyingRequest = new Request("https://test.com", { method: "post", body: formData, }); @@ -113,7 +109,7 @@ describe("parseMultipartFormData", () => { }, }); - let req = new NodeRequest("https://test.com", { + let req = new Request("https://test.com", { method: "post", body, headers: underlyingRequest.headers, @@ -132,12 +128,12 @@ describe("parseMultipartFormData", () => { }); it("when controller is closed", async () => { - let formData = new NodeFormData(); + let formData = new FormData(); formData.set("a", "value"); formData.set("blob", new Blob(["blob".repeat(1000)]), "blob.txt"); formData.set("file", new File(["file".repeat(1000)], "file.txt")); - let underlyingRequest = new NodeRequest("https://test.com", { + let underlyingRequest = new Request("https://test.com", { method: "post", body: formData, }); @@ -153,7 +149,7 @@ describe("parseMultipartFormData", () => { }, }); - let req = new NodeRequest("https://test.com", { + let req = new Request("https://test.com", { method: "post", body, headers: underlyingRequest.headers,