Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move http test to nock #20

Open
gr2m opened this issue Apr 12, 2019 · 0 comments
Open

Move http test to nock #20

gr2m opened this issue Apr 12, 2019 · 0 comments

Comments

@gr2m
Copy link
Member

gr2m commented Apr 12, 2019

propagate/tests/http.js

Lines 1 to 38 in cf3ca67

// I checked this in by accident. I'm ambivalent about whether we ought to
// include it. It's a reproduction of the bug from https://github.com/nock/propagate/pull/17
// though it doesn't elucidate the fix as well as directly testing the return
// values from .emit()
'use strict'
const { test } = require('tap')
const { EventEmitter } = require('events')
const propagate = require('..')
const http = require('http')
test('is able to propagate response from http.ClientRequest', function(t) {
t.plan(1)
const request = http.request({
hostname: 'google.com',
path: '/',
method: 'GET',
})
const ee1 = new EventEmitter()
propagate(request, ee1)
let retrievedData = ''
ee1.on('response', response => {
response.on('data', data => {
retrievedData = data.toString('utf8')
})
response.on('close', () => {
t.notEqual(retrievedData, '')
})
})
request.end()
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant