Windshaft-cartodb/test/unit/ported/windshaft-server-test.js

36 lines
1.1 KiB
JavaScript
Raw Normal View History

'use strict';
2019-10-07 17:29:07 +08:00
require('../../support/test-helper');
2015-07-08 06:12:32 +08:00
var assert = require('assert');
2019-10-07 17:29:07 +08:00
var cartodbServer = require('../../../lib/server');
var serverOptions = require('../../../lib/server-options');
2015-07-08 06:12:32 +08:00
2019-10-22 01:07:24 +08:00
describe('windshaft', function () {
it('should have valid global environment', function () {
2015-07-08 06:12:32 +08:00
assert.equal(global.environment.name, 'test');
});
2019-10-22 01:07:24 +08:00
it('can instantiate a Windshaft object (configured express instance)', function () {
2015-07-08 06:12:32 +08:00
var ws = cartodbServer(serverOptions);
assert.ok(ws);
});
2019-10-22 01:07:24 +08:00
it('can spawn a new server on the global listen port', function (done) {
2015-07-08 06:12:32 +08:00
var ws = cartodbServer(serverOptions);
2019-10-22 01:07:24 +08:00
var server = ws.listen(global.environment.port, function () {
2015-07-08 06:12:32 +08:00
assert.ok(ws);
server.close(done); /* allow proper tear down */
2015-07-08 06:12:32 +08:00
});
});
2019-10-22 01:07:24 +08:00
it('throws exception if incorrect options passed in', function () {
2015-07-08 06:12:32 +08:00
assert.throws(
2019-10-22 01:07:24 +08:00
function () {
var ws = cartodbServer({ unbuffered_logging: true });
2015-07-08 06:12:32 +08:00
ws.listen();
}, /Must initialise server with/
2015-07-08 06:12:32 +08:00
);
});
});