aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/js/web/html/FormData.test.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/js/web/html/FormData.test.ts b/test/js/web/html/FormData.test.ts
index c742bd33e..5e4861bc8 100644
--- a/test/js/web/html/FormData.test.ts
+++ b/test/js/web/html/FormData.test.ts
@@ -36,6 +36,36 @@ describe("FormData", () => {
expect(formData.getAll("foo")[0]).toBe("bar");
});
+ it("should get filename from file", async () => {
+ const blob = new Blob(["bar"]);
+ const formData = new FormData();
+ formData.append("foo", blob);
+ // @ts-expect-error
+ expect(formData.get("foo").name).toBeUndefined();
+ formData.append("foo2", new File([blob], "foo.txt"));
+ // @ts-expect-error
+ expect(formData.get("foo2").name).toBe("foo.txt");
+ });
+
+ it("should use the correct filenames", async () => {
+ const blob = new Blob(["bar"]) as any;
+ const form = new FormData();
+ form.append("foo", blob);
+ expect(blob.name).toBeUndefined();
+
+ let b1 = form.get("foo") as any;
+ expect(blob.name).toBeUndefined();
+ expect(b1.name).toBeUndefined();
+
+ form.set("foo", b1, "foo.txt");
+ expect(blob.name).toBeUndefined();
+ expect(b1.name).toBeUndefined();
+
+ b1 = form.get("foo") as Blob;
+ expect(blob.name).toBeUndefined();
+ expect(b1.name).toBe("foo.txt");
+ });
+
const multipartFormDataFixturesRawBody = [
{
name: "simple",