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

53 lines
1.2 KiB
JavaScript
Raw Normal View History

import endPointAPI from '../../../src/api/index';
2018-06-28 18:33:37 +02:00
import {API_ERROR} from '../../../src/lib/constants';
2017-04-19 21:15:28 +02:00
2018-06-28 18:33:37 +02:00
import express from 'express';
import request from 'request';
import rimraf from 'rimraf';
import config from '../partials/config/index';
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) {
rimraf(__dirname + '/store/test-storage', done);
2017-04-19 21:15:28 +02:00
});
2014-12-22 18:58:25 +01:00
beforeAll(async function(done) {
2017-11-01 17:47:20 +01: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) {
2018-06-28 18:33:37 +02:00
expect(err).toBeNull();
expect(body).toMatch(/<title>Verdaccio<\/title>/);
2017-04-19 21:15:28 +02:00
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({
2018-06-28 18:33:37 +02:00
url: `http://localhost:${port}/whatever`,
2014-12-22 18:58:25 +01:00
}, function(err, res, body) {
2018-06-28 18:33:37 +02:00
expect(err).toBeNull();
expect(body).toMatch(API_ERROR.NO_PACKAGE);
2017-04-19 21:15:28 +02:00
done();
});
});
});