1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/test/functional/newnpmreg.js

125 lines
4.2 KiB
JavaScript
Raw Permalink Normal View History

2017-04-19 21:15:28 +02:00
'use strict';
let assert = require('assert');
function readfile(x) {
2017-04-19 21:15:28 +02:00
return require('fs').readFileSync(__dirname + '/' + x);
}
function sha(x) {
2017-04-19 21:15:28 +02:00
return require('crypto').createHash('sha1', 'binary').update(x).digest('hex');
}
module.exports = function() {
2017-04-19 21:15:28 +02:00
let server = process.server;
let server2 = process.server2;
let express = process.express;
describe('newnpmreg', function() {
2017-04-19 21:15:28 +02:00
before(function() {
return server.request({
uri: '/testpkg-newnpmreg',
headers: {
'content-type': 'application/json',
},
method: 'PUT',
json: JSON.parse(readfile('fixtures/newnpmreg.json')),
2017-04-19 21:15:28 +02:00
}).status(201);
});
2017-04-19 21:15:28 +02:00
it('add pkg', function() {});
2017-04-19 21:15:28 +02:00
it('server1 - tarball', function() {
return server.getTarball('testpkg-newnpmreg', 'testpkg-newnpmreg-0.0.0.tgz')
.status(200)
2017-04-19 21:15:28 +02:00
.then(function(body) {
// not real sha due to utf8 conversion
2017-04-19 21:15:28 +02:00
assert.strictEqual(sha(body), '8ee7331cbc641581b1a8cecd9d38d744a8feb863');
});
});
2017-04-19 21:15:28 +02:00
it('server2 - tarball', function() {
return server2.getTarball('testpkg-newnpmreg', 'testpkg-newnpmreg-0.0.0.tgz')
.status(200)
2017-04-19 21:15:28 +02:00
.then(function(body) {
// not real sha due to utf8 conversion
2017-04-19 21:15:28 +02:00
assert.strictEqual(sha(body), '8ee7331cbc641581b1a8cecd9d38d744a8feb863');
});
});
2017-04-19 21:15:28 +02:00
it('server1 - package', function() {
return server.getPackage('testpkg-newnpmreg')
.status(200)
2017-04-19 21:15:28 +02:00
.then(function(body) {
assert.equal(body.name, 'testpkg-newnpmreg');
assert.equal(body.versions['0.0.0'].name, 'testpkg-newnpmreg');
assert.equal(body.versions['0.0.0'].dist.tarball, 'http://localhost:55551/testpkg-newnpmreg/-/testpkg-newnpmreg-0.0.0.tgz');
assert.deepEqual(body['dist-tags'], {foo: '0.0.0', latest: '0.0.0'});
});
});
it('server2 - package', function() {
return server2.getPackage('testpkg-newnpmreg')
.status(200)
2017-04-19 21:15:28 +02:00
.then(function(body) {
assert.equal(body.name, 'testpkg-newnpmreg');
assert.equal(body.versions['0.0.0'].name, 'testpkg-newnpmreg');
assert.equal(body.versions['0.0.0'].dist.tarball, 'http://localhost:55552/testpkg-newnpmreg/-/testpkg-newnpmreg-0.0.0.tgz');
assert.deepEqual(body['dist-tags'], {foo: '0.0.0', latest: '0.0.0'});
});
});
2017-07-08 18:35:28 +02:00
// FIXME: Review this block of test
// it('server1 - readme', function() {
// return server.request({uri: '/-/readme/testpkg-newnpmreg'})
// .status(200)
// .then(function(body) {
// assert.equal(body, '<p>blah blah blah</p>\n');
// });
// });
//
// it('server2 - readme', function() {
// return server2.request({uri: '/-/readme/testpkg-newnpmreg'})
// .status(200)
// .then(function(body) {
// assert.equal(body, '<p>blah blah blah</p>\n');
// });
// });
describe('search', function() {
function check(obj) {
2017-04-19 21:15:28 +02:00
obj['testpkg-newnpmreg'].time.modified = '2014-10-02T07:07:51.000Z';
assert.deepEqual(obj['testpkg-newnpmreg'],
2017-04-19 21:15:28 +02:00
{'name': 'testpkg-newnpmreg',
'description': '',
'author': '',
'license': 'ISC',
'dist-tags': {latest: '0.0.0'},
'maintainers': [{name: 'alex', email: 'alex@kocharin.ru'}],
'readmeFilename': '',
'time': {modified: '2014-10-02T07:07:51.000Z'},
'versions': {},
'repository': {type: 'git', url: ''}});
}
2017-04-19 21:15:28 +02:00
before(function() {
express.get('/-/all', function(req, res) {
2017-04-19 21:15:28 +02:00
res.send({});
});
});
2017-04-19 21:15:28 +02:00
it('server1 - search', function() {
return server.request({uri: '/-/all'})
.status(200)
2017-04-19 21:15:28 +02:00
.then(check);
});
2017-04-19 21:15:28 +02:00
it('server2 - search', function() {
return server2.request({uri: '/-/all'})
.status(200)
2017-04-19 21:15:28 +02:00
.then(check);
});
});
});
};