0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00
verdaccio/test/unit/basic_system.spec.js

54 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-04-19 14:15:28 -05:00
'use strict';
2017-08-02 13:45:21 -05:00
const assert = require('assert');
const express = require('express');
const request = require('request');
const rimraf = require('rimraf');
2018-01-17 16:44:16 -05:00
const verdaccio = require('../../src/api/index');
2017-08-02 13:45:21 -05:00
const config = require('./partials/config');
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;
2014-12-22 12:58:25 -05:00
2017-11-01 11:47:20 -05:00
beforeAll(function(done) {
rimraf(__dirname + '/store/test-storage', done);
2017-04-19 14:15:28 -05:00
});
2014-12-22 12:58:25 -05:00
2017-11-01 11:47:20 -05:00
beforeAll(function(done) {
2017-04-19 14:15:28 -05:00
app.use(verdaccio(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) {
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
2017-11-01 11:47:20 -05:00
test('server should respond on /whatever', done => {
2014-12-22 12:58:25 -05:00
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();
});
});
});