From ec36521ab8dcfe470901a7678c613e2a3c98daa3 Mon Sep 17 00:00:00 2001 From: "Juan Picado @jotadeveloper" Date: Sun, 28 Jan 2018 11:53:49 +0100 Subject: [PATCH] fix(dist-tag): fix #411 latest tag is incorrect --- src/api/endpoint/api/package.js | 4 +--- test/unit/api.spec.js | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/api/endpoint/api/package.js b/src/api/endpoint/api/package.js index ff7203fd0..323d9b712 100644 --- a/src/api/endpoint/api/package.js +++ b/src/api/endpoint/api/package.js @@ -1,5 +1,3 @@ -'use strict'; - const _ = require('lodash'); const createError = require('http-errors'); @@ -30,7 +28,7 @@ module.exports = function(route, auth, storage, config) { if (_.isNil(info['dist-tags'][queryVersion]) === false) { queryVersion = info['dist-tags'][queryVersion]; t = Utils.get_version(info, queryVersion); - if (_.isNil(t)) { + if (_.isNil(t) === false) { return next(t); } } diff --git a/test/unit/api.spec.js b/test/unit/api.spec.js index 1c640e71e..3c9288d96 100644 --- a/test/unit/api.spec.js +++ b/test/unit/api.spec.js @@ -208,6 +208,42 @@ describe('endpoint unit test', () => { }); }); + test('should fetch jquery specific version package from remote uplink', (done) => { + + request(app) + .get('/jquery/1.5.1') + .set('content-type', 'application/json; charset=utf-8') + .expect('Content-Type', /json/) + .expect(200) + .end(function(err, res) { + if (err) { + return done(err); + } + + expect(res.body).toBeDefined(); + expect(res.body.name).toMatch(/jquery/); + done(); + }); + }); + + test('should fetch jquery specific tag package from remote uplink', (done) => { + + request(app) + .get('/jquery/latest') + .set('content-type', 'application/json; charset=utf-8') + .expect('Content-Type', /json/) + .expect(200) + .end(function(err, res) { + if (err) { + return done(err); + } + + expect(res.body).toBeDefined(); + expect(res.body.name).toMatch(/jquery/); + done(); + }); + }); + test('should not found a unexisting remote package under scope', (done) => { request(app)