Skip to content

Commit 48887cb

Browse files
committed
test: add test
Signed-off-by: Logan McAnsh <[email protected]>
1 parent f962790 commit 48887cb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/form-data/test/form-data.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,28 @@ export const test = (test) => {
239239
assert.equal("blob", file.name);
240240
});
241241

242+
test("Allows passing a form element", () => {
243+
const form = document.createElement("form");
244+
const insideInput = document.createElement("input");
245+
const outsideInput = document.createElement("input");
246+
247+
// `form` on an input is "read-only"
248+
outsideInput.innerHTML = `<input type="text" name="form" value="outside" form="my-form">`;
249+
250+
insideInput.type = "text";
251+
insideInput.name = "form";
252+
insideInput.value = "inside";
253+
254+
form.appendChild(insideInput);
255+
form.id = "my-form";
256+
257+
document.body.appendChild(form);
258+
document.body.appendChild(outsideInput);
259+
260+
const formData = new FormData(form);
261+
assert.equal(formData.getAll("form"), ["inside", "outside"]);
262+
})
263+
242264
test.skip("complicated form", () => {
243265
const data = new FormData();
244266
data.append("blobs", new Blob(["basic"]));

0 commit comments

Comments
 (0)