Adding test for ssl disabled

This commit is contained in:
Javier Cervantes 2014-04-24 10:14:16 -05:00
parent 956e757e8e
commit 224287744a
1 changed files with 35 additions and 12 deletions

View File

@ -9,19 +9,20 @@ var API = source('api');
describe("API", function() {
var api, opts;
beforeEach(function() {
stub(https, 'createServer').returns({ listen: spy() });
opts = { master: { name: 'master' } }
api = new API(opts);
});
afterEach(function() {
https.createServer.restore();
});
describe("constructor", function() {
beforeEach(function() {
stub(https, 'createServer').returns({ listen: spy() });
opts = { master: { name: 'master' } }
api = new API(opts);
});
afterEach(function() {
https.createServer.restore();
});
it("sets @opts to the passed opts object", function() {
expect(api.opts).to.be.eql(opts);
});
@ -56,6 +57,28 @@ describe("API", function() {
var title = api.server.get('title');
expect(title).to.be.eql("Cylon API Server");
});
});
describe("ssl disabled", function () {
beforeEach(function() {
stub(https, 'createServer').returns({ listen: spy() });
opts = { ssl: false }
api = new API(opts);
});
afterEach(function() {
https.createServer.restore();
});
it("doesn't create https server", function() {
expect(https.createServer).not.to.be.calledWith();
});
});
describe("#configureRoutes", function() {