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

48 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-04-19 21:15:28 +02:00
'use strict';
2017-08-02 20:45:21 +02:00
const assert = require('assert');
const express = require('express');
const request = require('request');
const rimraf = require('rimraf');
const verdaccio = require('../../');
const config = require('./partials/config');
2014-12-22 18:58:25 +01:00
2017-08-02 20:45:21 +02:00
describe('basic system test', function() {
2017-04-19 21:15:28 +02:00
let port;
2014-12-22 18:58:25 +01:00
before(function(done) {
rimraf(__dirname + '/store/test-storage', done);
2017-04-19 21:15:28 +02:00
});
2014-12-22 18:58:25 +01:00
before(function(done) {
2017-04-19 21:15:28 +02:00
let app = express();
app.use(verdaccio(config));
2014-12-22 18:58:25 +01:00
2017-08-02 20:45:21 +02:00
const server = require('http').createServer(app);
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-08-02 20:45:21 +02:00
it('server should respond on /', function(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-08-02 20:45:21 +02:00
it('server should respond on /whatever', function(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();
});
});
});