2017-04-19 14:15:28 -05:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
let assert = require('assert');
|
|
|
|
let express = require('express');
|
|
|
|
let request = require('request');
|
|
|
|
let rimraf = require('rimraf');
|
|
|
|
let verdaccio = require('../../');
|
|
|
|
let config = require('./partials/config');
|
2014-12-22 12:58:25 -05:00
|
|
|
|
|
|
|
describe('toplevel', function() {
|
2017-04-19 14:15:28 -05:00
|
|
|
let port;
|
2014-12-22 12:58:25 -05:00
|
|
|
|
|
|
|
before(function(done) {
|
2017-07-01 17:05:58 -05:00
|
|
|
rimraf(__dirname + '/store/test-storage', done);
|
2017-04-19 14:15:28 -05:00
|
|
|
});
|
2014-12-22 12:58:25 -05:00
|
|
|
|
|
|
|
before(function(done) {
|
2017-04-19 14:15:28 -05:00
|
|
|
let app = express();
|
|
|
|
app.use(verdaccio(config));
|
2014-12-22 12:58:25 -05:00
|
|
|
|
2017-04-19 14:15:28 -05:00
|
|
|
let server = require('http').createServer(app);
|
2014-12-22 12:58:25 -05:00
|
|
|
server.listen(0, function() {
|
2017-04-19 14:15:28 -05:00
|
|
|
port = server.address().port;
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2014-12-22 12:58:25 -05:00
|
|
|
|
|
|
|
it('should respond on /', function(done) {
|
|
|
|
request({
|
|
|
|
url: 'http://localhost:' + port + '/',
|
|
|
|
}, function(err, res, body) {
|
2017-04-19 14:15:28 -05:00
|
|
|
assert.equal(err, null);
|
|
|
|
assert(body.match(/<title>Verdaccio<\/title>/));
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2014-12-22 12:58:25 -05:00
|
|
|
|
|
|
|
it('should respond on /whatever', function(done) {
|
|
|
|
request({
|
|
|
|
url: 'http://localhost:' + port + '/whatever',
|
|
|
|
}, function(err, res, body) {
|
2017-04-19 14:15:28 -05:00
|
|
|
assert.equal(err, null);
|
|
|
|
assert(body.match(/no such package available/));
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|