fix: fix ClientRequest.getUploadProgress (#21388)
This commit is contained in:
parent
dc9beda182
commit
092e00f7f0
2 changed files with 12 additions and 1 deletions
|
@ -1205,6 +1205,17 @@ describe('net module', () => {
|
|||
})
|
||||
})
|
||||
|
||||
it('should report upload progress', async () => {
|
||||
const serverUrl = await respondOnce.toSingleURL((request, response) => {
|
||||
response.end()
|
||||
})
|
||||
const netRequest = net.request({ url: serverUrl, method: 'POST' })
|
||||
expect(netRequest.getUploadProgress()).to.deep.equal({ active: false })
|
||||
netRequest.end(Buffer.from('hello'))
|
||||
const [position, total] = await emittedOnce(netRequest, 'upload-progress')
|
||||
expect(netRequest.getUploadProgress()).to.deep.equal({ active: true, started: true, current: position, total })
|
||||
})
|
||||
|
||||
it('should emit error event on server socket destroy', async () => {
|
||||
const serverUrl = await respondOnce.toSingleURL((request) => {
|
||||
request.socket.destroy()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue