2018-06-17 06:34:59 -05:00
|
|
|
import endPointAPI from '../../../src/api/index';
|
2018-06-28 11:33:37 -05:00
|
|
|
import {API_ERROR} from '../../../src/lib/constants';
|
2017-04-19 14:15:28 -05:00
|
|
|
|
2018-06-28 11:33:37 -05:00
|
|
|
import express from 'express';
|
|
|
|
import request from 'request';
|
|
|
|
import rimraf from 'rimraf';
|
|
|
|
import config from '../partials/config/index';
|
2014-12-22 12:58:25 -05:00
|
|
|
|
2017-11-01 11:47:20 -05:00
|
|
|
const app = express();
|
|
|
|
const server = require('http').createServer(app);
|
|
|
|
|
|
|
|
describe('basic system test', () => {
|
2017-04-19 14:15:28 -05:00
|
|
|
let port;
|
2019-07-08 02:20:16 -05:00
|
|
|
jest.setTimeout(20000);
|
2014-12-22 12:58:25 -05:00
|
|
|
|
2017-11-01 11:47:20 -05:00
|
|
|
beforeAll(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
|
|
|
|
2018-04-21 11:36:06 -05:00
|
|
|
beforeAll(async function(done) {
|
2017-11-01 11:47:20 -05:00
|
|
|
|
2019-02-24 17:20:25 -05:00
|
|
|
app.use(await endPointAPI(config()));
|
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
|
|
|
|
2017-11-01 11:47:20 -05:00
|
|
|
afterAll((done) => {
|
|
|
|
server.close(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('server should respond on /', done => {
|
2014-12-22 12:58:25 -05:00
|
|
|
request({
|
|
|
|
url: 'http://localhost:' + port + '/',
|
|
|
|
}, function(err, res, body) {
|
2018-06-28 11:33:37 -05:00
|
|
|
expect(err).toBeNull();
|
2018-09-06 14:26:54 -05:00
|
|
|
expect(body).toMatch(/Verdaccio/);
|
2017-04-19 14:15:28 -05:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2014-12-22 12:58:25 -05:00
|
|
|
|
2019-03-04 17:39:33 -05:00
|
|
|
test('server should respond on /___not_found_package', done => {
|
2014-12-22 12:58:25 -05:00
|
|
|
request({
|
2019-03-04 17:39:33 -05:00
|
|
|
url: `http://localhost:${port}/___not_found_package`,
|
2014-12-22 12:58:25 -05:00
|
|
|
}, function(err, res, body) {
|
2018-06-28 11:33:37 -05:00
|
|
|
expect(err).toBeNull();
|
|
|
|
expect(body).toMatch(API_ERROR.NO_PACKAGE);
|
2017-04-19 14:15:28 -05:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|