Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
KhafraDev committed Feb 25, 2024
1 parent 4f5b3a8 commit ddcf065
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/issue-2065.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { tspl } = require('@matteo.collina/tspl')
const { test, after } = require('node:test')
const { createServer } = require('node:http')
const { once } = require('node:events')
const { openAsBlob } = require('node:fs')
const { File, FormData, request } = require('..')

test('undici.request with a FormData body should set content-length header', async (t) => {
Expand All @@ -25,3 +26,21 @@ test('undici.request with a FormData body should set content-length header', asy
body
})
})

test('undici.request with a FormData stream value should set transfer-encoding header', { skip: !openAsBlob }, async (t) => {
const server = createServer((req, res) => {
t.ok(req.headers['content-type'].startsWith('multipart/form-data'))
res.end()
}).listen(0)

t.teardown(server.close.bind(server))

Check failure on line 36 in test/issue-2065.js

View workflow job for this annotation

GitHub Actions / Test / test (20, ubuntu-latest)

undici.request with a FormData stream value should set transfer-encoding header

[Error [ERR_TEST_FAILURE]: t.teardown is not a function] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: TypeError [Error]: t.teardown is not a function at TestContext.<anonymous> (/home/runner/work/undici/undici/test/issue-2065.js:36:5) at Test.runInAsyncScope (node:async_hooks:206:9) at Test.run (node:internal/test_runner/test:631:25) at Test.processPendingSubtests (node:internal/test_runner/test:374:18) at Test.postRun (node:internal/test_runner/test:715:19) at Test.run (node:internal/test_runner/test:673:12) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async startSubtest (node:internal/test_runner/harness:216:3) }

Check failure on line 36 in test/issue-2065.js

View workflow job for this annotation

GitHub Actions / Test / test (21, ubuntu-latest, experimental)

undici.request with a FormData stream value should set transfer-encoding header

[Error [ERR_TEST_FAILURE]: t.teardown is not a function] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: TypeError [Error]: t.teardown is not a function at TestContext.<anonymous> (/home/runner/work/undici/undici/test/issue-2065.js:36:5) at Test.runInAsyncScope (node:async_hooks:206:9) at Test.run (node:internal/test_runner/test:631:25) at Test.processPendingSubtests (node:internal/test_runner/test:374:18) at Test.postRun (node:internal/test_runner/test:715:19) at Test.run (node:internal/test_runner/test:673:12) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async startSubtest (node:internal/test_runner/harness:218:3) }
await once(server, 'listening')

const body = new FormData()
body.set('file', await openAsBlob(__filename), 'streamfile')

await request(`http://localhost:${server.address().port}`, {
method: 'POST',
body
})
})

0 comments on commit ddcf065

Please sign in to comment.