Ghost/core/test/ghost/ghost_spec.js
2013-06-01 11:14:05 -04:00

49 lines
1.2 KiB
JavaScript

/*globals describe, beforeEach, it*/
(function () {
"use strict";
var should = require('should'),
when = require('when'),
sinon = require('sinon'),
Ghost = require('../../ghost');
describe("Ghost API", function () {
it("is a singleton", function () {
var ghost1 = new Ghost(),
ghost2 = new Ghost();
should.strictEqual(ghost1, ghost2);
});
it("uses init() to initialize", function (done) {
var ghost = new Ghost(),
fakeDataProvider = {
init: function () {
return when.resolve();
}
},
dataProviderInitSpy = sinon.spy(fakeDataProvider, "init"),
oldDataProvder = ghost.dataProvider;
ghost.dataProvider = fakeDataProvider;
should.not.exist(ghost.globals());
ghost.init().then(function () {
should.exist(ghost.globals());
dataProviderInitSpy.called.should.equal(true);
ghost.dataProvider = oldDataProvder;
done();
}).then(null, done);
});
});
}());