Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/npm-registry-client/test/request-gzip-content.js')
-rw-r--r--node_modules/npm-registry-client/test/request-gzip-content.js52
1 files changed, 27 insertions, 25 deletions
diff --git a/node_modules/npm-registry-client/test/request-gzip-content.js b/node_modules/npm-registry-client/test/request-gzip-content.js
index 2c7dcae59..79c2e8dc0 100644
--- a/node_modules/npm-registry-client/test/request-gzip-content.js
+++ b/node_modules/npm-registry-client/test/request-gzip-content.js
@@ -1,45 +1,47 @@
-var zlib = require('zlib')
-var tap = require('tap')
-var server = require('./fixtures/server.js')
-var RC = require('../')
+var zlib = require("zlib")
+var tap = require("tap")
+
+var server = require("./lib/server.js")
+var common = require("./lib/common.js")
+var client = common.freshClient({
+ "fetch-retries" : 1,
+ "fetch-retry-mintimeout" : 10,
+ "fetch-retry-maxtimeout" : 100
+})
+
+var TEST_URL = "http://localhost:1337/some-package-gzip/1.2.3"
+
var pkg = {
- _id: 'some-package-gzip@1.2.3',
- name: 'some-package-gzip',
- version: '1.2.3'
+ _id: "some-package-gzip@1.2.3",
+ name: "some-package-gzip",
+ version: "1.2.3"
}
zlib.gzip(JSON.stringify(pkg), function (err, pkgGzip) {
- var client = new RC({
- cache: __dirname + '/fixtures/cache'
- , 'fetch-retries': 1
- , 'fetch-retry-mintimeout': 10
- , 'fetch-retry-maxtimeout': 100
- , registry: 'http://localhost:' + server.port })
-
- tap.test('request gzip package content', function (t) {
- server.expect('GET', '/some-package-gzip/1.2.3', function (req, res) {
+ tap.test("request gzip package content", function (t) {
+ server.expect("GET", "/some-package-gzip/1.2.3", function (req, res) {
res.statusCode = 200
- res.setHeader('Content-Encoding', 'gzip');
- res.setHeader('Content-Type', 'application/json');
+ res.setHeader("Content-Encoding", "gzip");
+ res.setHeader("Content-Type", "application/json");
res.end(pkgGzip)
})
- client.get('/some-package-gzip/1.2.3', function (er, data, raw, res) {
+ client.get(TEST_URL, null, function (er, data) {
if (er) throw er
t.deepEqual(data, pkg)
t.end()
})
})
- tap.test('request wrong gzip package content', function (t) {
- server.expect('GET', '/some-package-gzip-error/1.2.3', function (req, res) {
+ tap.test("request wrong gzip package content", function (t) {
+ server.expect("GET", "/some-package-gzip-error/1.2.3", function (req, res) {
res.statusCode = 200
- res.setHeader('Content-Encoding', 'gzip')
- res.setHeader('Content-Type', 'application/json')
- res.end(new Buffer('wrong gzip content'))
+ res.setHeader("Content-Encoding", "gzip")
+ res.setHeader("Content-Type", "application/json")
+ res.end(new Buffer("wrong gzip content"))
})
- client.get('/some-package-gzip-error/1.2.3', function (er, data, raw, res) {
+ client.get(TEST_URL, null, function (er) {
t.ok(er)
t.end()
})