Implements module tests

closes #2521
- Add new module tests
- Implements new `test-module` task to specifically run module tests
This commit is contained in:
Fabian Becker 2014-09-27 17:26:26 +00:00
parent 24a7739e8a
commit 40254adc92
2 changed files with 76 additions and 1 deletions

View File

@ -275,6 +275,13 @@ var _ = require('lodash'),
src: [
'core/test/functional/routes/**/*_test.js'
]
},
// #### All Module tests
module: {
src: [
'core/test/functional/module/**/*_test.js'
]
}
},
@ -764,7 +771,7 @@ var _ = require('lodash'),
// details of each of the test suites.
//
grunt.registerTask('test', 'Run tests and lint code',
['jshint', 'jscs', 'test-routes', 'test-unit', 'test-integration', 'test-functional']);
['jshint', 'jscs', 'test-routes', 'test-module', 'test-unit', 'test-integration', 'test-functional']);
// ### Lint
//
@ -841,6 +848,14 @@ var _ = require('lodash'),
grunt.registerTask('test-routes', 'Run functional route tests (mocha)',
['clean:test', 'setTestEnv', 'ensureConfig', 'mochacli:routes']);
// ### Module tests *(sub task)*
// `grunt test-module` will run just the module tests
//
// The purpose of the module tests is to ensure that Ghost can be used as an npm module and exposes all
// required methods to interact with it.
grunt.registerTask('test-module', 'Run functional module tests (mocha)',
['clean:test', 'setTestEnv', 'ensureConfig', 'mochacli:module']);
// ### Functional tests for the setup process
// `grunt test-functional-setup will run just the functional tests for the setup page.
//

View File

@ -0,0 +1,60 @@
/*global describe, it */
/*jshint expr:true*/
// # Module tests
// This tests using Ghost as an npm module
var should = require('should'),
ghost = require('../../../../core');
describe('Module', function () {
describe('Setup', function () {
it('should resolve with a ghost-server instance', function (done) {
ghost().then(function (ghostServer) {
should.exist(ghostServer);
done();
}).catch(function (e) {
done(e);
});
});
it('should expose an express instance', function (done) {
ghost().then(function (ghostServer) {
should.exist(ghostServer);
should.exist(ghostServer.rootApp);
done();
}).catch(function (e) {
done(e);
});
});
it('should expose configuration values', function (done) {
ghost().then(function (ghostServer) {
should.exist(ghostServer);
should.exist(ghostServer.config);
should.exist(ghostServer.config.server);
should.exist(ghostServer.config.paths);
should.exist(ghostServer.config.paths.subdir);
should.equal(ghostServer.config.paths.subdir, '');
done();
}).catch(function (e) {
done(e);
});
});
it('should have start/stop/restart functions', function (done) {
ghost().then(function (ghostServer) {
should.exist(ghostServer);
ghostServer.start.should.be.a.Function;
ghostServer.restart.should.be.a.Function;
ghostServer.stop.should.be.a.Function;
done();
}).catch(function (e) {
done(e);
});
});
});
});