2018-04-21 18:36:06 +02:00
|
|
|
import endPointAPI from '../../src/api/index';
|
2017-04-19 21:15:28 +02:00
|
|
|
|
2017-08-02 20:45:21 +02:00
|
|
|
const assert = require('assert');
|
|
|
|
const express = require('express');
|
|
|
|
const request = require('request');
|
|
|
|
const rimraf = require('rimraf');
|
2018-03-10 23:13:26 +01:00
|
|
|
|
2017-08-02 20:45:21 +02:00
|
|
|
const config = require('./partials/config');
|
2014-12-22 18:58:25 +01:00
|
|
|
|
2017-11-01 17:47:20 +01:00
|
|
|
const app = express();
|
|
|
|
const server = require('http').createServer(app);
|
|
|
|
|
|
|
|
describe('basic system test', () => {
|
2017-04-19 21:15:28 +02:00
|
|
|
let port;
|
2014-12-22 18:58:25 +01:00
|
|
|
|
2017-11-01 17:47:20 +01:00
|
|
|
beforeAll(function(done) {
|
2017-07-02 00:05:58 +02:00
|
|
|
rimraf(__dirname + '/store/test-storage', done);
|
2017-04-19 21:15:28 +02:00
|
|
|
});
|
2014-12-22 18:58:25 +01:00
|
|
|
|
2018-04-21 18:36:06 +02:00
|
|
|
beforeAll(async function(done) {
|
2017-11-01 17:47:20 +01:00
|
|
|
|
2018-04-21 18:36:06 +02:00
|
|
|
app.use(await endPointAPI(config));
|
2014-12-22 18:58:25 +01:00
|
|
|
|
|
|
|
server.listen(0, function() {
|
2017-04-19 21:15:28 +02:00
|
|
|
port = server.address().port;
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2014-12-22 18:58:25 +01:00
|
|
|
|
2017-11-01 17:47:20 +01:00
|
|
|
afterAll((done) => {
|
|
|
|
server.close(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('server should respond on /', done => {
|
2014-12-22 18:58:25 +01:00
|
|
|
request({
|
|
|
|
url: 'http://localhost:' + port + '/',
|
|
|
|
}, function(err, res, body) {
|
2017-04-19 21:15:28 +02:00
|
|
|
assert.equal(err, null);
|
|
|
|
assert(body.match(/<title>Verdaccio<\/title>/));
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2014-12-22 18:58:25 +01:00
|
|
|
|
2017-11-01 17:47:20 +01:00
|
|
|
test('server should respond on /whatever', done => {
|
2014-12-22 18:58:25 +01:00
|
|
|
request({
|
|
|
|
url: 'http://localhost:' + port + '/whatever',
|
|
|
|
}, function(err, res, body) {
|
2017-04-19 21:15:28 +02:00
|
|
|
assert.equal(err, null);
|
|
|
|
assert(body.match(/no such package available/));
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|