1 var zlib = require('zlib')
2 var test = require('tap').test
4 var server = require('./lib/server.js')
5 var common = require('./lib/common.js')
6 var client = common.freshClient({
14 var TEST_URL = common.registry + '/some-package-gzip/1.2.3'
17 _id: 'some-package-gzip@1.2.3',
18 name: 'some-package-gzip',
22 zlib.gzip(JSON.stringify(pkg), function (err, pkgGzip) {
23 test('request gzip package content', function (t) {
24 t.ifError(err, 'example package compressed')
26 server.expect('GET', '/some-package-gzip/1.2.3', function (req, res) {
28 res.setHeader('Content-Encoding', 'gzip')
29 res.setHeader('Content-Type', 'application/json')
33 client.get(TEST_URL, {}, function (er, data) {
35 t.deepEqual(data, pkg, 'some-package-gzip version 1.2.3')
40 test('request wrong gzip package content', function (t) {
42 for (var i = 0; i < 3; i++) {
43 server.expect('GET', '/some-package-gzip/1.2.3', function (req, res) {
45 res.setHeader('Content-Encoding', 'gzip')
46 res.setHeader('Content-Type', 'application/json')
47 res.end(new Buffer('wrong gzip content'))
51 client.get(TEST_URL, {}, function (er) {
52 t.ok(er, 'ungzip error')
57 test('cleanup', function (t) {