Skip to content

Commit

Permalink
nock#1836 fixes expected Node behaviour for http.get
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethaasan committed Jan 9, 2020
1 parent 6b9303f commit ed81a90
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_common.js
Expand Up @@ -512,3 +512,26 @@ test('testing timers are deleted correctly', t => {
t.end()
})
})

test('correct node behavior', t => {
const scope = nock('http://example.test')
.get('/')
.reply()

const req = sinon.spy()
const origHttpReq = http.request;

http.request = req;

http.get('http://example.test', res => {
t.equal(res.statusCode, 200)

res.on('data', req)

res.on('end', () => {
expect(req).to.have.been.notCalled()
scope.done()
t.end()
})
})
})

0 comments on commit ed81a90

Please sign in to comment.