mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Refactoring tests to always run as expected
closes #721 - we now have grunt test-unit for safely running unit tests.
This commit is contained in:
parent
01f6551bf2
commit
e9d2646997
3 changed files with 31 additions and 32 deletions
44
Gruntfile.js
44
Gruntfile.js
|
@ -346,6 +346,11 @@ var path = require('path'),
|
|||
|
||||
grunt.initConfig(cfg);
|
||||
|
||||
grunt.registerTask('setTestEnv', function () {
|
||||
// Use 'testing' Ghost config; unless we are running on travis (then show queries for debugging)
|
||||
process.env.NODE_ENV = process.env.TRAVIS ? 'travis' : 'testing';
|
||||
});
|
||||
|
||||
// Update the package information after changes
|
||||
grunt.registerTask('updateCurrentPackageInfo', function () {
|
||||
cfg.pkg = grunt.file.readJSON('package.json');
|
||||
|
@ -383,28 +388,6 @@ var path = require('path'),
|
|||
});
|
||||
});
|
||||
|
||||
// Prepare the project for development
|
||||
// TODO: Git submodule init/update (https://github.com/jaubourg/grunt-update-submodules)?
|
||||
grunt.registerTask("init", ["shell:bourbon", "sass:admin", 'handlebars']);
|
||||
|
||||
// Run API tests only
|
||||
grunt.registerTask("test-api", ["mochacli:api"]);
|
||||
|
||||
// Run permisisons tests only
|
||||
grunt.registerTask("test-p", ["mochacli:perm"]);
|
||||
|
||||
// Run migrations tests only
|
||||
grunt.registerTask("test-m", ["mochacli:migrate"]);
|
||||
|
||||
// Run casperjs tests only
|
||||
grunt.registerTask('test-functional', ['express:test', 'spawn-casperjs']);
|
||||
|
||||
// Run tests and lint code
|
||||
grunt.registerTask("validate", ["jslint", "mochacli:all", "test-functional"]);
|
||||
|
||||
// Generate Docs
|
||||
grunt.registerTask("docs", ["groc"]);
|
||||
|
||||
/* Generate Changelog
|
||||
* - Pulls changelog from git, excluding merges.
|
||||
* - Uses first line of commit message. Includes committer name.
|
||||
|
@ -698,6 +681,23 @@ var path = require('path'),
|
|||
"watch"
|
||||
]);
|
||||
|
||||
|
||||
// Prepare the project for development
|
||||
// TODO: Git submodule init/update (https://github.com/jaubourg/grunt-update-submodules)?
|
||||
grunt.registerTask("init", ["shell:bourbon", "sass:admin", 'handlebars']);
|
||||
|
||||
// Run unit tests
|
||||
grunt.registerTask("test-unit", ['setTestEnv', "mochacli:all"]);
|
||||
|
||||
// Run casperjs tests only
|
||||
grunt.registerTask('test-functional', ['setTestEnv', 'express:test', 'spawn-casperjs']);
|
||||
|
||||
// Run tests and lint code
|
||||
grunt.registerTask("validate", ["jslint", "mochacli:all", "test-functional"]);
|
||||
|
||||
// Generate Docs
|
||||
grunt.registerTask("docs", ["groc"]);
|
||||
|
||||
// When you just say "grunt"
|
||||
grunt.registerTask("default", ['sass:admin', 'handlebars']);
|
||||
};
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
/*globals describe, beforeEach, it*/
|
||||
var admin = require('../../server/controllers/admin'),
|
||||
fs = require('fs-extra'),
|
||||
var testUtils = require('./testUtils'),
|
||||
should = require('should'),
|
||||
sinon = require('sinon'),
|
||||
when = require('when');
|
||||
when = require('when'),
|
||||
fs = require('fs-extra'),
|
||||
|
||||
// Stuff we are testing
|
||||
admin = require('../../server/controllers/admin');
|
||||
describe('Admin Controller', function() {
|
||||
describe('uploader', function() {
|
||||
|
||||
|
@ -36,7 +38,7 @@ describe('Admin Controller', function() {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
describe('valid file', function() {
|
||||
|
||||
var clock;
|
||||
|
@ -56,7 +58,7 @@ describe('Admin Controller', function() {
|
|||
});
|
||||
|
||||
it('can upload jpg', function(done) {
|
||||
clock = sinon.useFakeTimers(42);
|
||||
clock = sinon.useFakeTimers(42);
|
||||
sinon.stub(res, 'send', function(data) {
|
||||
data.should.not.equal(404);
|
||||
return done();
|
||||
|
@ -67,7 +69,7 @@ describe('Admin Controller', function() {
|
|||
|
||||
it('can upload png', function(done) {
|
||||
req.files.uploadimage.name = "IMAGE.png";
|
||||
clock = sinon.useFakeTimers(42);
|
||||
clock = sinon.useFakeTimers(42);
|
||||
sinon.stub(res, 'send', function(data) {
|
||||
data.should.not.equal(404);
|
||||
return done();
|
||||
|
@ -78,7 +80,7 @@ describe('Admin Controller', function() {
|
|||
|
||||
it('can upload gif', function(done) {
|
||||
req.files.uploadimage.name = "IMAGE.gif";
|
||||
clock = sinon.useFakeTimers(42);
|
||||
clock = sinon.useFakeTimers(42);
|
||||
sinon.stub(res, 'send', function(data) {
|
||||
data.should.not.equal(404);
|
||||
return done();
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
// Use 'testing' Ghost config; unless we are running on travis (then show queries for debugging)
|
||||
process.env.NODE_ENV = process.env.TRAVIS ? 'travis' : 'testing';
|
||||
|
||||
var knex = require('../../server/models/base').Knex,
|
||||
when = require('when'),
|
||||
migration = require("../../server/data/migration/"),
|
||||
|
|
Loading…
Add table
Reference in a new issue