2020-08-13 16:27:00 -05:00
|
|
|
import path from 'path';
|
2020-03-03 17:59:19 -05:00
|
|
|
import express from 'express';
|
|
|
|
import request from 'request';
|
|
|
|
|
2020-11-15 05:14:09 -05:00
|
|
|
import { API_ERROR } from '@verdaccio/commons-api';
|
2020-11-05 17:22:09 -05:00
|
|
|
import { parseConfigFile } from '@verdaccio/config';
|
2020-03-03 17:59:19 -05:00
|
|
|
import { setup } from '@verdaccio/logger';
|
|
|
|
|
|
|
|
import endPointAPI from '../../src';
|
|
|
|
|
2020-08-13 16:27:00 -05:00
|
|
|
setup([{ type: 'stdout', format: 'pretty', level: 'trace' }]);
|
2020-03-03 17:59:19 -05:00
|
|
|
|
|
|
|
const app = express();
|
|
|
|
const server = require('http').createServer(app);
|
|
|
|
|
|
|
|
const parseConfigurationFile = (conf) => {
|
|
|
|
return path.join(__dirname, `./${conf}`);
|
|
|
|
};
|
|
|
|
|
2021-03-06 12:56:45 -05:00
|
|
|
// TODO: restore when web module is ready
|
|
|
|
describe.skip('basic system test', () => {
|
2020-03-03 17:59:19 -05:00
|
|
|
let port;
|
|
|
|
jest.setTimeout(20000);
|
|
|
|
|
2020-08-13 16:27:00 -05:00
|
|
|
beforeAll(async function (done) {
|
2020-03-03 17:59:19 -05:00
|
|
|
const config = parseConfigFile(parseConfigurationFile('basic.yaml'));
|
|
|
|
app.use(await endPointAPI(config));
|
2020-08-13 16:27:00 -05:00
|
|
|
server.listen(0, function () {
|
2020-03-03 17:59:19 -05:00
|
|
|
port = server.address().port;
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll((done) => {
|
|
|
|
server.close(done);
|
|
|
|
});
|
|
|
|
|
2020-08-13 16:27:00 -05:00
|
|
|
test('server should respond on /', (done) => {
|
|
|
|
request(
|
|
|
|
{
|
|
|
|
url: 'http://localhost:' + port + '/',
|
|
|
|
},
|
|
|
|
function (err, res, body) {
|
|
|
|
expect(err).toBeNull();
|
|
|
|
expect(body).toMatch(/Verdaccio/);
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
);
|
2020-03-03 17:59:19 -05:00
|
|
|
});
|
|
|
|
|
2020-08-13 16:27:00 -05:00
|
|
|
test('server should respond on /___not_found_package', (done) => {
|
|
|
|
request(
|
|
|
|
{
|
|
|
|
json: true,
|
|
|
|
url: `http://localhost:${port}/___not_found_package`,
|
|
|
|
},
|
|
|
|
function (err, res, body) {
|
|
|
|
expect(err).toBeNull();
|
|
|
|
expect(body.error).toMatch(API_ERROR.NO_PACKAGE);
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
);
|
2020-03-03 17:59:19 -05:00
|
|
|
});
|
|
|
|
});
|