mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Merge pull request #4203 from halfdan/2521-module-test
Implements Ghost module tests
This commit is contained in:
commit
593d3b184b
2 changed files with 76 additions and 1 deletions
17
Gruntfile.js
17
Gruntfile.js
|
@ -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.
|
||||
//
|
||||
|
|
60
core/test/functional/module/module_test.js
Normal file
60
core/test/functional/module/module_test.js
Normal 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);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue