Skip to content

Commit

Permalink
test: add regression test for nodejs#1814 (nodejs#1815)
Browse files Browse the repository at this point in the history
  • Loading branch information
KhafraDev authored and anonrig committed Apr 4, 2023
1 parent 0cbf96a commit 095b1dc
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion test/fetch/formdata.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const { test } = require('tap')
const { FormData, File } = require('../../')
const { FormData, File, Response } = require('../../')
const { Blob: ThirdPartyBlob } = require('formdata-node')
const { Blob } = require('buffer')

Expand Down Expand Up @@ -296,3 +296,22 @@ test('arguments', (t) => {

t.end()
})

// https://github.com/nodejs/undici/pull/1814
test('FormData returned from bodyMixin.formData is not a clone', async (t) => {
const fd = new FormData()
fd.set('foo', 'bar')

const res = new Response(fd)
fd.set('foo', 'foo')

const fd2 = await res.formData()

t.equal(fd2.get('foo'), 'bar')
t.equal(fd.get('foo'), 'foo')

fd2.set('foo', 'baz')

t.equal(fd2.get('foo'), 'baz')
t.equal(fd.get('foo'), 'foo')
})

0 comments on commit 095b1dc

Please sign in to comment.