|
1 | 1 | import { FormData } from "@remix-run/web-form-data";
|
2 | 2 | import * as lib from "@remix-run/web-form-data";
|
3 | 3 | import { File, Blob } from "@remix-run/web-file";
|
4 |
| -import { JSDOM } from 'jsdom'; |
5 | 4 | import { assert } from "./test.js";
|
6 | 5 |
|
7 | 6 | /**
|
8 | 7 | * @param {import('./test').Test} test
|
9 | 8 | */
|
10 | 9 | export const test = (test) => {
|
11 |
| - test("test baisc", async () => { |
| 10 | + test("test basic", async () => { |
12 | 11 | assert.equal(typeof FormData, "function");
|
13 | 12 | assert.isEqual(typeof lib.FormData, "function");
|
14 | 13 | });
|
@@ -261,38 +260,27 @@ export const test = (test) => {
|
261 | 260 | );
|
262 | 261 | });
|
263 | 262 |
|
264 |
| - test("Should allow passing a form element", () => { |
265 |
| - test.before(() => { |
266 |
| - const { window } = new JSDOM('<main></main>'); |
267 |
| - // @ts-ignore |
268 |
| - global.window = window; |
269 |
| - global.document = window.document; |
270 |
| - global.navigator = window.navigator; |
271 |
| - global.getComputedStyle = window.getComputedStyle; |
272 |
| - }) |
273 |
| - |
274 |
| - test("pass a form element", () => { |
275 |
| - const form = document.createElement("form"); |
276 |
| - const insideInput = document.createElement("input"); |
277 |
| - const outsideInput = document.createElement("input"); |
278 |
| - |
279 |
| - outsideInput.type = "text"; |
280 |
| - outsideInput.name = "form"; |
281 |
| - outsideInput.value = "outside"; |
282 |
| - outsideInput.setAttribute("form", "my-form"); |
283 |
| - |
284 |
| - insideInput.type = "text"; |
285 |
| - insideInput.name = "form"; |
286 |
| - insideInput.value = "inside"; |
287 |
| - |
288 |
| - form.appendChild(insideInput); |
289 |
| - form.id = "my-form"; |
290 |
| - |
291 |
| - document.body.appendChild(form); |
292 |
| - document.body.appendChild(outsideInput); |
293 |
| - |
294 |
| - const formData = new FormData(form); |
295 |
| - assert.equal(formData.getAll("form"), ["inside", "outside"]); |
296 |
| - }) |
| 263 | + test("Should allow passing a form element", () => { |
| 264 | + const form = document.createElement("form"); |
| 265 | + const insideInput = document.createElement("input"); |
| 266 | + const outsideInput = document.createElement("input"); |
| 267 | + |
| 268 | + outsideInput.type = "text"; |
| 269 | + outsideInput.name = "form"; |
| 270 | + outsideInput.value = "outside"; |
| 271 | + outsideInput.setAttribute("form", "my-form"); |
| 272 | + |
| 273 | + insideInput.type = "text"; |
| 274 | + insideInput.name = "form"; |
| 275 | + insideInput.value = "inside"; |
| 276 | + |
| 277 | + form.appendChild(insideInput); |
| 278 | + form.id = "my-form"; |
| 279 | + |
| 280 | + document.body.appendChild(form); |
| 281 | + document.body.appendChild(outsideInput); |
| 282 | + |
| 283 | + const formData = new FormData(form); |
| 284 | + assert.equal(formData.getAll("form"), ["inside", "outside"]); |
297 | 285 | })
|
298 | 286 | };
|
0 commit comments