summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/npm-registry-client/test
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/npm-registry-client/test')
-rw-r--r--deps/npm/node_modules/npm-registry-client/test/00-setup.js5
-rw-r--r--deps/npm/node_modules/npm-registry-client/test/config-defaults.js2
-rw-r--r--deps/npm/node_modules/npm-registry-client/test/fetch-streaming.js58
-rw-r--r--deps/npm/node_modules/npm-registry-client/test/initialize.js4
-rw-r--r--deps/npm/node_modules/npm-registry-client/test/lib/common.js8
-rw-r--r--deps/npm/node_modules/npm-registry-client/test/zz-cleanup.js5
6 files changed, 75 insertions, 7 deletions
diff --git a/deps/npm/node_modules/npm-registry-client/test/00-setup.js b/deps/npm/node_modules/npm-registry-client/test/00-setup.js
index 747768fb85..fb9585a428 100644
--- a/deps/npm/node_modules/npm-registry-client/test/00-setup.js
+++ b/deps/npm/node_modules/npm-registry-client/test/00-setup.js
@@ -1,8 +1,9 @@
-var tap = require('tap')
+var join = require('path').join
var rimraf = require('rimraf')
+var tap = require('tap')
tap.test('setup', function (t) {
- rimraf(__dirname + '/fixtures/cache', function (er) {
+ rimraf(join(__dirname, 'fixtures', 'cache'), function (er) {
if (er) throw er
t.pass('cache cleaned')
t.end()
diff --git a/deps/npm/node_modules/npm-registry-client/test/config-defaults.js b/deps/npm/node_modules/npm-registry-client/test/config-defaults.js
index a432da8581..ca6983a1ba 100644
--- a/deps/npm/node_modules/npm-registry-client/test/config-defaults.js
+++ b/deps/npm/node_modules/npm-registry-client/test/config-defaults.js
@@ -33,7 +33,7 @@ test('config defaults', function (t) {
})
test('missing HTTPS proxy defaults to HTTP proxy', function (t) {
- var client = common.freshClient({ proxy: { http: 'http://proxy.npm:8088/' }})
+ var client = common.freshClient({ proxy: { http: 'http://proxy.npm:8088/' } })
t.equal(client.config.proxy.http, 'http://proxy.npm:8088/', 'HTTP proxy set')
t.equal(client.config.proxy.http, client.config.proxy.https, 'HTTP === HTTPS')
diff --git a/deps/npm/node_modules/npm-registry-client/test/fetch-streaming.js b/deps/npm/node_modules/npm-registry-client/test/fetch-streaming.js
new file mode 100644
index 0000000000..72aeea0beb
--- /dev/null
+++ b/deps/npm/node_modules/npm-registry-client/test/fetch-streaming.js
@@ -0,0 +1,58 @@
+var test = require('tap').test
+var concat = require('concat-stream')
+
+var server = require('./lib/server.js')
+var common = require('./lib/common.js')
+var client = common.freshClient()
+
+var testData = JSON.stringify({test: true})
+var errorData = JSON.stringify({error: 'it went bad'})
+
+test('streaming fetch', function (t) {
+ server.expect('/test', function (req, res) {
+ t.equal(req.method, 'GET', 'got expected method')
+
+ res.writeHead(200, {
+ 'content-type': 'application/json'
+ })
+
+ res.end(testData)
+ })
+
+ server.expect('/error', function (req, res) {
+ t.equal(req.method, 'GET', 'got expected method')
+
+ res.writeHead(401, {
+ 'content-type': 'application/json'
+ })
+
+ res.end(errorData)
+ })
+
+ client.fetch(
+ 'http://localhost:1337/test',
+ { streaming: true },
+ function (er, res) {
+ t.ifError(er, 'loaded successfully')
+
+ var sink = concat(function (data) {
+ t.deepEqual(data.toString(), testData)
+ client.fetch(
+ 'http://localhost:1337/error',
+ { streaming: true },
+ function (er, res) {
+ t.ok(er, 'got an error')
+ server.close()
+ t.end()
+ }
+ )
+ })
+
+ res.on('error', function (error) {
+ t.ifError(error, 'no errors on stream')
+ })
+
+ res.pipe(sink)
+ }
+ )
+})
diff --git a/deps/npm/node_modules/npm-registry-client/test/initialize.js b/deps/npm/node_modules/npm-registry-client/test/initialize.js
index 3856b67b45..4a97bd5fdf 100644
--- a/deps/npm/node_modules/npm-registry-client/test/initialize.js
+++ b/deps/npm/node_modules/npm-registry-client/test/initialize.js
@@ -83,7 +83,7 @@ test('referer set on client', function (t) {
})
test('initializing with proxy explicitly disabled', function (t) {
- var client = new Client({ proxy: { http: false }})
+ var client = new Client({ proxy: { http: false } })
var options = client.initialize(
'http://localhost:1337/',
'GET',
@@ -96,7 +96,7 @@ test('initializing with proxy explicitly disabled', function (t) {
})
test('initializing with proxy undefined', function (t) {
- var client = new Client({ proxy: { http: undefined }})
+ var client = new Client({ proxy: { http: undefined } })
var options = client.initialize(
'http://localhost:1337/',
'GET',
diff --git a/deps/npm/node_modules/npm-registry-client/test/lib/common.js b/deps/npm/node_modules/npm-registry-client/test/lib/common.js
index 78e543f699..ea48d30149 100644
--- a/deps/npm/node_modules/npm-registry-client/test/lib/common.js
+++ b/deps/npm/node_modules/npm-registry-client/test/lib/common.js
@@ -10,6 +10,14 @@ if (!global.setImmediate || !require('timers').setImmediate) {
}
}
+// See https://github.com/npm/npm-registry-client/pull/142 for background.
+// Note: `process.on('warning')` only works with Node >= 6.
+process.on('warning', function (warning) {
+ if (/Possible EventEmitter memory leak detected/.test(warning.message)) {
+ throw new Error('There should not be any EventEmitter memory leaks')
+ }
+})
+
module.exports = {
port: server.port,
registry: REGISTRY,
diff --git a/deps/npm/node_modules/npm-registry-client/test/zz-cleanup.js b/deps/npm/node_modules/npm-registry-client/test/zz-cleanup.js
index 35253c7acd..16e4ee8a1d 100644
--- a/deps/npm/node_modules/npm-registry-client/test/zz-cleanup.js
+++ b/deps/npm/node_modules/npm-registry-client/test/zz-cleanup.js
@@ -1,8 +1,9 @@
-var tap = require('tap')
+var join = require('path').join
var rimraf = require('rimraf')
+var tap = require('tap')
tap.test('teardown', function (t) {
- rimraf(__dirname + '/fixtures/cache', function (er) {
+ rimraf(join(__dirname, 'fixtures', 'cache'), function (er) {
if (er) throw er
t.pass('cache cleaned')
t.end()