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 d37aded commit af4ad03
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tests/test_common.js
Expand Up @@ -17,7 +17,6 @@ const common = require('../lib/common')
const matchBody = require('../lib/match_body')
const sinon = require('sinon')
const nock = require('..')
const { expect } = require('chai')

require('./cleanup_after_each')()

Expand Down Expand Up @@ -519,18 +518,18 @@ test('correct node behavior', t => {
.get('/')
.reply()

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

http.request = req
http.request = reqSpy

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

res.on('data', req)
res.on('data', reqSpy)

res.on('end', () => {
expect(req).to.have.been.notCalled()
t.equal(reqSpy.called, false)
scope.done()
http.request = origHttpReq
t.end()
Expand Down

0 comments on commit af4ad03

Please sign in to comment.