-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test to ensure full type when parsing multipart/form-data' (#…
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict' | ||
|
||
const { tspl } = require('@matteo.collina/tspl') | ||
const { describe, test } = require('node:test') | ||
const { FormData, Response } = require('..') | ||
|
||
describe('https://github.com/nodejs/undici/issues/2283', () => { | ||
test('preserve full type when parsing multipart/form-data', async (t) => { | ||
t = tspl(t, { plan: 2 }) | ||
const testBlob = new Blob(['123'], { type: 'text/plain;charset=utf-8' }) | ||
const fd = new FormData() | ||
fd.set('x', testBlob) | ||
const res = new Response(fd) | ||
res.clone().text().then(body => | ||
// Just making sure that it contains ;charset=utf-8 | ||
t.ok(body.includes('text/plain;charset=utf-8')) | ||
) | ||
|
||
new Response(fd).formData().then(fd => { | ||
// returns just 'text/plain' | ||
t.ok(fd.get('x').type === 'text/plain;charset=utf-8') | ||
}) | ||
|
||
await t.completed | ||
}) | ||
}) |