2013-11-11 10:37:09 +00:00
|
|
|
/*globals describe, before, beforeEach, afterEach, it*/
|
2013-11-07 14:26:47 +01:00
|
|
|
var testUtils = require('../utils'),
|
2013-09-06 17:07:25 +01:00
|
|
|
should = require('should'),
|
2013-06-25 12:43:15 +01:00
|
|
|
sinon = require('sinon'),
|
2013-09-06 17:07:25 +01:00
|
|
|
when = require('when'),
|
2013-07-10 23:45:13 +01:00
|
|
|
path = require('path'),
|
|
|
|
_ = require('underscore'),
|
2013-09-06 17:07:25 +01:00
|
|
|
|
|
|
|
// Stuff we are testing
|
2013-11-20 08:58:52 -05:00
|
|
|
config = require('../../server/config'),
|
|
|
|
Ghost = require('../../ghost');
|
2013-05-26 12:17:46 -05:00
|
|
|
|
2013-06-25 12:43:15 +01:00
|
|
|
describe("Ghost API", function () {
|
2013-11-27 21:45:01 -05:00
|
|
|
var sandbox,
|
2013-07-10 23:45:13 +01:00
|
|
|
ghost;
|
|
|
|
|
2013-09-15 00:21:29 +01:00
|
|
|
before(function (done) {
|
|
|
|
testUtils.clearData().then(function () {
|
|
|
|
done();
|
|
|
|
}, done);
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function (done) {
|
2013-09-23 22:37:36 -05:00
|
|
|
sandbox = sinon.sandbox.create();
|
|
|
|
|
2013-09-15 00:21:29 +01:00
|
|
|
testUtils.initData().then(function () {
|
|
|
|
ghost = new Ghost();
|
|
|
|
done();
|
|
|
|
}, done);
|
2013-07-10 23:45:13 +01:00
|
|
|
});
|
2013-05-26 12:17:46 -05:00
|
|
|
|
2013-09-23 22:37:36 -05:00
|
|
|
afterEach(function () {
|
|
|
|
sandbox.restore();
|
|
|
|
});
|
|
|
|
|
2013-11-24 15:29:36 +01:00
|
|
|
after(function (done) {
|
|
|
|
testUtils.clearData().then(function () {
|
|
|
|
done();
|
|
|
|
}, done);
|
|
|
|
});
|
|
|
|
|
2013-06-25 12:43:15 +01:00
|
|
|
it("is a singleton", function () {
|
2013-09-23 22:37:36 -05:00
|
|
|
var ghost2 = new Ghost();
|
2013-05-26 12:17:46 -05:00
|
|
|
|
2013-09-23 22:37:36 -05:00
|
|
|
should.strictEqual(ghost, ghost2);
|
2013-06-25 12:43:15 +01:00
|
|
|
});
|
2013-05-26 12:17:46 -05:00
|
|
|
|
2013-06-25 12:43:15 +01:00
|
|
|
it("uses init() to initialize", function (done) {
|
2013-09-23 22:37:36 -05:00
|
|
|
var dataProviderInitMock = sandbox.stub(ghost.dataProvider, "init", function () {
|
2013-08-05 10:11:32 -05:00
|
|
|
return when.resolve();
|
|
|
|
});
|
2013-05-30 09:01:29 -05:00
|
|
|
|
2013-06-25 12:43:15 +01:00
|
|
|
should.not.exist(ghost.settings());
|
2013-05-30 09:01:29 -05:00
|
|
|
|
2013-06-25 12:43:15 +01:00
|
|
|
ghost.init().then(function () {
|
2013-06-01 10:47:41 -04:00
|
|
|
|
2013-06-25 12:43:15 +01:00
|
|
|
should.exist(ghost.settings());
|
2013-05-30 09:01:29 -05:00
|
|
|
|
2013-08-05 10:11:32 -05:00
|
|
|
dataProviderInitMock.called.should.equal(true);
|
2013-05-30 09:01:29 -05:00
|
|
|
|
2013-06-25 12:43:15 +01:00
|
|
|
done();
|
2013-08-05 10:11:32 -05:00
|
|
|
}, done);
|
2013-06-01 10:47:41 -04:00
|
|
|
|
2013-06-25 12:43:15 +01:00
|
|
|
});
|
|
|
|
});
|