Skip to content

Commit e94093a

Browse files
authored
test: add regression test for nodejs#1814 (nodejs#1815)
1 parent d2cd116 commit e94093a

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

test/fetch/formdata.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
const { test } = require('tap')
4-
const { FormData, File } = require('../../')
4+
const { FormData, File, Response } = require('../../')
55
const { Blob: ThirdPartyBlob } = require('formdata-node')
66
const { Blob } = require('buffer')
77

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

297297
t.end()
298298
})
299+
300+
// https://github.com/nodejs/undici/pull/1814
301+
test('FormData returned from bodyMixin.formData is not a clone', async (t) => {
302+
const fd = new FormData()
303+
fd.set('foo', 'bar')
304+
305+
const res = new Response(fd)
306+
fd.set('foo', 'foo')
307+
308+
const fd2 = await res.formData()
309+
310+
t.equal(fd2.get('foo'), 'bar')
311+
t.equal(fd.get('foo'), 'foo')
312+
313+
fd2.set('foo', 'baz')
314+
315+
t.equal(fd2.get('foo'), 'baz')
316+
t.equal(fd.get('foo'), 'foo')
317+
})

0 commit comments

Comments
 (0)