Skip to content

Commit

Permalink
refactor(remix-server-runtime): use native Fetch API
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed Aug 22, 2023
1 parent cdd6927 commit 689cbd7
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions packages/remix-server-runtime/__tests__/formData-test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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,
});
Expand Down Expand Up @@ -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,
});
Expand All @@ -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,
});
Expand All @@ -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,
});
Expand All @@ -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,
Expand All @@ -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,
});
Expand All @@ -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,
Expand Down

0 comments on commit 689cbd7

Please sign in to comment.