More test fixing

This commit is contained in:
Girish Ramakrishnan
2017-11-27 18:05:16 -08:00
parent 68c26c1d12
commit e6eb54d572
3 changed files with 64 additions and 62 deletions

View File

@@ -25,6 +25,7 @@ describe('Server', function () {
before(function () {
config._reset();
config.setFqdn('example-server-test.com');
config.set('provider', 'notcaas'); // otherwise, cron sets a caas timer for heartbeat causing the test to not quit
});
@@ -92,22 +93,22 @@ describe('Server', function () {
superagent.get(SERVER_URL + '/api/v1/cloudron/status', function (err, res) {
expect(err).to.not.be.ok();
expect(res.statusCode).to.equal(200);
expect(res.body.version).to.equal('0.5.0');
expect(res.body.version).to.equal('1.1.1-test');
done();
});
});
it('status route is GET', function (done) {
superagent.post(SERVER_URL + '/api/v1/cloudron/status')
.end(function (err, res) {
expect(res.statusCode).to.equal(404);
.end(function (err, res) {
expect(res.statusCode).to.equal(404);
superagent.get(SERVER_URL + '/api/v1/cloudron/status')
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
done();
superagent.get(SERVER_URL + '/api/v1/cloudron/status')
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
done();
});
});
});
});
});
@@ -228,21 +229,21 @@ describe('Server', function () {
.set('Access-Control-Request-Headers', 'accept, origin, x-superagented-with')
.set('Origin', 'http://localhost')
.end(function (error, res) {
expect(res.headers['access-control-allow-methods']).to.be('GET, PUT, DELETE, POST, OPTIONS');
expect(res.headers['access-control-allow-credentials']).to.be('false');
expect(res.headers['access-control-allow-headers']).to.be('accept, origin, x-superagented-with'); // mirrored from superagent
expect(res.headers['access-control-allow-origin']).to.be('http://localhost'); // mirrors from superagent
done();
});
expect(res.headers['access-control-allow-methods']).to.be('GET, PUT, DELETE, POST, OPTIONS');
expect(res.headers['access-control-allow-credentials']).to.be('false');
expect(res.headers['access-control-allow-headers']).to.be('accept, origin, x-superagented-with'); // mirrored from superagent
expect(res.headers['access-control-allow-origin']).to.be('http://localhost'); // mirrors from superagent
done();
});
});
it('does not crash for malformed origin', function (done) {
superagent('OPTIONS', SERVER_URL + '/api/v1/cloudron/status')
.set('Origin', 'foobar')
.end(function (error, res) {
expect(res.statusCode).to.be(405);
done();
});
expect(res.statusCode).to.be(405);
done();
});
});
after(function (done) {