more async'ification
This commit is contained in:
@@ -18,11 +18,10 @@ const SERVER_URL = 'http://localhost:' + constants.PORT;
|
||||
|
||||
describe('Server', function () {
|
||||
describe('startup', function () {
|
||||
it('succeeds', function (done) {
|
||||
server.start(function (error) {
|
||||
expect(error).to.not.be.ok();
|
||||
done();
|
||||
});
|
||||
after(server.stop);
|
||||
|
||||
it('succeeds', async function () {
|
||||
await server.start();
|
||||
});
|
||||
|
||||
it('is reachable', async function () {
|
||||
@@ -30,28 +29,15 @@ describe('Server', function () {
|
||||
expect(response.status).to.equal(200);
|
||||
});
|
||||
|
||||
it('should fail because already running', function (done) {
|
||||
expect(server.start).to.throwException(function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
after(function (done) {
|
||||
server.stop(function () {
|
||||
done();
|
||||
});
|
||||
it('should fail because already running', async function () {
|
||||
const [error] = await safe(server.start());
|
||||
expect(error).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe('runtime', function () {
|
||||
before(function (done) {
|
||||
server.start(done);
|
||||
});
|
||||
|
||||
after(async function () {
|
||||
await database._clear();
|
||||
await util.promisify(server.stop)();
|
||||
});
|
||||
before(server.start);
|
||||
after(server.stop);
|
||||
|
||||
it('random bad superagents', async function () {
|
||||
const response = await superagent.get(SERVER_URL + '/random').ok(() => true);
|
||||
@@ -74,15 +60,8 @@ describe('Server', function () {
|
||||
});
|
||||
|
||||
describe('config', function () {
|
||||
before(function (done) {
|
||||
server.start(done);
|
||||
});
|
||||
|
||||
after(function (done) {
|
||||
server.stop(function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
before(server.start);
|
||||
after(server.stop);
|
||||
|
||||
it('config fails due missing token', async function () {
|
||||
const response = await superagent.get(SERVER_URL + '/api/v1/config').ok(() => true);
|
||||
@@ -96,15 +75,7 @@ describe('Server', function () {
|
||||
});
|
||||
|
||||
describe('shutdown', function () {
|
||||
before(function (done) {
|
||||
server.start(done);
|
||||
});
|
||||
|
||||
it('succeeds', function (done) {
|
||||
server.stop(function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
before(server.stop);
|
||||
|
||||
it('is not reachable anymore', async function () {
|
||||
const [error] = await safe(superagent.get(SERVER_URL + '/api/v1/cloudron/status').ok(() => true));
|
||||
@@ -113,11 +84,8 @@ describe('Server', function () {
|
||||
});
|
||||
|
||||
describe('cors', function () {
|
||||
before(function (done) {
|
||||
server.start(function (error) {
|
||||
done(error);
|
||||
});
|
||||
});
|
||||
before(server.start);
|
||||
after(server.stop);
|
||||
|
||||
it('responds to OPTIONS', async function () {
|
||||
const response = await superagent('OPTIONS', SERVER_URL + '/api/v1/cloudron/status')
|
||||
@@ -137,11 +105,5 @@ describe('Server', function () {
|
||||
.ok(() => true);
|
||||
expect(response.status).to.be(405);
|
||||
});
|
||||
|
||||
after(function (done) {
|
||||
server.stop(function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user