Skip to content

Commit

Permalink
Add test for busboy emitting error
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron-robey committed Sep 9, 2022
1 parent 0a9785b commit 0b4c505
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/fetch/client-fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,37 @@ test('multipart formdata not base64', async (t) => {
})
})

test('busboy emit error', async (t) => {
t.plan(1)

const formData = new FormData()
formData.append('field1', 'value1')

const tempRes = new Response(formData)
const formRaw = await tempRes.text()

const server = createServer((req, res) => {
res.setHeader('content-type', 'multipart/form-data; boundary=wrongboundary')
res.write(formRaw)
res.end()
})
t.teardown(server.close.bind(server))

await new Promise((resolve) => {
server.listen(0, async () => {
const response = await fetch(`http://localhost:${server.address().port}`)

try {
await response.formData()
} catch (err) {
t.equal(err.message, 'Unexpected end of form')
}

resolve()
})
})
})

test('multipart formdata base64', async (t) => {
t.plan(1)

Expand Down

0 comments on commit 0b4c505

Please sign in to comment.