summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/test/test.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/test/test.js')
-rw-r--r--deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/test/test.js72
1 files changed, 15 insertions, 57 deletions
diff --git a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/test/test.js b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/test/test.js
index da2e919835..23814e2c32 100644
--- a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/test/test.js
+++ b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-proxy-agent/node_modules/agent-base/test/test.js
@@ -14,10 +14,6 @@ var events = require('events');
var inherits = require('util').inherits;
var Agent = require('../');
-var PassthroughAgent = Agent(function(req, opts) {
- return opts.secureEndpoint ? https.globalAgent : http.globalAgent;
-});
-
describe('Agent', function() {
describe('subclass', function() {
it('should be subclassable', function(done) {
@@ -74,10 +70,10 @@ describe('Agent', function() {
it('should be the Agent instance', function(done) {
var called = false;
var agent = new Agent();
- agent.callback = function() {
+ agent.callback = function () {
called = true;
assert.equal(this, agent);
- };
+ }
var info = url.parse('http://127.0.0.1/foo');
info.agent = agent;
var req = http.get(info);
@@ -85,15 +81,15 @@ describe('Agent', function() {
assert(/no Duplex stream was returned/.test(err.message));
done();
});
- });
+ })
it('should be the Agent instance with callback signature', function(done) {
var called = false;
var agent = new Agent();
- agent.callback = function(req, opts, fn) {
+ agent.callback = function (req, opts, fn) {
called = true;
assert.equal(this, agent);
fn();
- };
+ }
var info = url.parse('http://127.0.0.1/foo');
info.agent = agent;
var req = http.get(info);
@@ -101,8 +97,8 @@ describe('Agent', function() {
assert(/no Duplex stream was returned/.test(err.message));
done();
});
- });
- });
+ })
+ })
describe('"error" event', function() {
it('should be invoked on `http.ClientRequest` instance if `callback()` has not been defined', function(
done
@@ -205,7 +201,13 @@ describe('Agent', function() {
'Set-Cookie: 1\r\n' +
'Set-Cookie: 2\r\n\r\n'
);
- stream.emit('data', buf);
+ if ('function' == typeof stream.ondata) {
+ // node <= v0.11.3
+ stream.ondata(buf, 0, buf.length);
+ } else {
+ // node > v0.11.3
+ stream.emit('data', buf);
+ }
});
req.end();
@@ -397,28 +399,6 @@ describe('"http" module', function() {
done();
});
});
-
- describe('PassthroughAgent', function() {
- it('should pass through to `http.globalAgent`', function(done) {
- // add HTTP server "request" listener
- var gotReq = false;
- server.once('request', function(req, res) {
- gotReq = true;
- res.setHeader('X-Foo', 'bar');
- res.setHeader('X-Url', req.url);
- res.end();
- });
-
- var info = url.parse('http://127.0.0.1:' + port + '/foo');
- info.agent = PassthroughAgent;
- http.get(info, function(res) {
- assert.equal('bar', res.headers['x-foo']);
- assert.equal('/foo', res.headers['x-url']);
- assert(gotReq);
- done();
- });
- });
- });
});
describe('"https" module', function() {
@@ -446,6 +426,7 @@ describe('"https" module', function() {
server.close();
});
+
it('should not modify the passed in Options object', function(done) {
var called = false;
var agent = new Agent(function(req, opts, fn) {
@@ -534,29 +515,6 @@ describe('"https" module', function() {
rejectUnauthorized: false
});
});
-
- describe('PassthroughAgent', function() {
- it('should pass through to `https.globalAgent`', function(done) {
- // add HTTP server "request" listener
- var gotReq = false;
- server.once('request', function(req, res) {
- gotReq = true;
- res.setHeader('X-Foo', 'bar');
- res.setHeader('X-Url', req.url);
- res.end();
- });
-
- var info = url.parse('https://127.0.0.1:' + port + '/foo');
- info.agent = PassthroughAgent;
- info.rejectUnauthorized = false;
- https.get(info, function(res) {
- assert.equal('bar', res.headers['x-foo']);
- assert.equal('/foo', res.headers['x-url']);
- assert(gotReq);
- done();
- });
- });
- });
});
describe('"ws" server', function() {