mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Merge pull request #70 from jgable/testsCleanup
Tests cleanup; convert to mocha
This commit is contained in:
commit
aae31780b0
11 changed files with 51 additions and 102 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -28,4 +28,5 @@ projectFilesBackup
|
||||||
/core/admin/assets/sass/config.rb
|
/core/admin/assets/sass/config.rb
|
||||||
/core/admin/assets/sass/layouts/config.rb
|
/core/admin/assets/sass/layouts/config.rb
|
||||||
/core/admin/assets/sass/modules/config.rb
|
/core/admin/assets/sass/modules/config.rb
|
||||||
|
/core/admin/assets/sass/modules/bourbon
|
||||||
/ghost/.idea/
|
/ghost/.idea/
|
13
Gruntfile.js
13
Gruntfile.js
|
@ -21,12 +21,6 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
// Unit test all the things!
|
|
||||||
nodeunit: {
|
|
||||||
all: ['core/test/ghost/**/test-*.js'],
|
|
||||||
api: ['core/test/ghost/test-api.js']
|
|
||||||
},
|
|
||||||
|
|
||||||
mochaTest: {
|
mochaTest: {
|
||||||
options: {
|
options: {
|
||||||
ui: "bdd",
|
ui: "bdd",
|
||||||
|
@ -35,6 +29,10 @@
|
||||||
|
|
||||||
all: {
|
all: {
|
||||||
src: ['core/test/**/*_spec.js']
|
src: ['core/test/**/*_spec.js']
|
||||||
|
},
|
||||||
|
|
||||||
|
api: {
|
||||||
|
src: ['core/test/**/api*_spec.js']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -57,7 +55,6 @@
|
||||||
grunt.initConfig(cfg);
|
grunt.initConfig(cfg);
|
||||||
|
|
||||||
grunt.loadNpmTasks("grunt-jslint");
|
grunt.loadNpmTasks("grunt-jslint");
|
||||||
grunt.loadNpmTasks("grunt-contrib-nodeunit");
|
|
||||||
grunt.loadNpmTasks("grunt-mocha-test");
|
grunt.loadNpmTasks("grunt-mocha-test");
|
||||||
grunt.loadNpmTasks("grunt-contrib-sass");
|
grunt.loadNpmTasks("grunt-contrib-sass");
|
||||||
grunt.loadNpmTasks("grunt-shell");
|
grunt.loadNpmTasks("grunt-shell");
|
||||||
|
@ -67,7 +64,7 @@
|
||||||
grunt.registerTask("init", ["shell:bourbon", "sass:admin"]);
|
grunt.registerTask("init", ["shell:bourbon", "sass:admin"]);
|
||||||
|
|
||||||
// Run API tests only
|
// Run API tests only
|
||||||
grunt.registerTask("test-api", ["nodeunit:api", "mochaTest:all"]);
|
grunt.registerTask("test-api", ["mochaTest:api"]);
|
||||||
|
|
||||||
// Run tests and lint code
|
// Run tests and lint code
|
||||||
grunt.registerTask("validate", ["jslint", "mochaTest:all"]);
|
grunt.registerTask("validate", ["jslint", "mochaTest:all"]);
|
||||||
|
|
|
@ -86,8 +86,7 @@
|
||||||
api.users.add({email_address: req.body.email_address, password: req.body.password}).then(function (user) {
|
api.users.add({email_address: req.body.email_address, password: req.body.password}).then(function (user) {
|
||||||
console.log('user added', user);
|
console.log('user added', user);
|
||||||
res.redirect('/ghost/login/');
|
res.redirect('/ghost/login/');
|
||||||
},
|
}, function (error) {
|
||||||
function(error) {
|
|
||||||
console.log('there was an error', error);
|
console.log('there was an error', error);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -66,7 +66,8 @@
|
||||||
var test = {
|
var test = {
|
||||||
email_address: _userdata.email
|
email_address: _userdata.email
|
||||||
};
|
};
|
||||||
models.User.forge(test).fetch().then(function (user) {
|
|
||||||
|
this.model.forge(test).fetch().then(function (user) {
|
||||||
var _user;
|
var _user;
|
||||||
bcrypt.compare(_userdata.pw, user.attributes.password, function (err, res) {
|
bcrypt.compare(_userdata.pw, user.attributes.password, function (err, res) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
20
core/test/ghost/dataProvider.json_spec.js
Normal file
20
core/test/ghost/dataProvider.json_spec.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
/*globals describe, beforeEach, it*/
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var should = require('should'),
|
||||||
|
DataProvider = require('../../shared/models/dataProvider.json');
|
||||||
|
|
||||||
|
describe("dataProvider.json", function () {
|
||||||
|
|
||||||
|
it("is a singleton", function() {
|
||||||
|
var provider1 = new DataProvider(),
|
||||||
|
provider2 = new DataProvider();
|
||||||
|
|
||||||
|
should.strictEqual(provider1, provider2);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}());
|
20
core/test/ghost/ghost_spec.js
Normal file
20
core/test/ghost/ghost_spec.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
/*globals describe, beforeEach, it*/
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var should = require('should'),
|
||||||
|
Ghost = require('../../ghost');
|
||||||
|
|
||||||
|
describe("Ghost API", function () {
|
||||||
|
|
||||||
|
it("is a singleton", function() {
|
||||||
|
var ghost1 = new Ghost(),
|
||||||
|
ghost2 = new Ghost();
|
||||||
|
|
||||||
|
should.strictEqual(ghost1, ghost2);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}());
|
|
@ -11,9 +11,10 @@
|
||||||
|
|
||||||
helpers = {
|
helpers = {
|
||||||
resetData: function () {
|
resetData: function () {
|
||||||
|
|
||||||
return migrations.one.down().then(function () {
|
return migrations.one.down().then(function () {
|
||||||
return migrations.one.up();
|
return migrations.one.up();
|
||||||
|
}, function() {
|
||||||
|
throw new Error("Failed to reset data");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*global require, module */
|
|
||||||
(function () {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
// Use 'testing' Ghost config
|
|
||||||
process.env.NODE_ENV = 'testing';
|
|
||||||
|
|
||||||
var _ = require('underscore'),
|
|
||||||
assert = require('assert'),
|
|
||||||
helpers = require('./helpers'),
|
|
||||||
fixtures = require('../../shared/data/fixtures/001'),
|
|
||||||
api = require('../../shared/data/api');
|
|
||||||
|
|
||||||
function fail(err) {
|
|
||||||
process.nextTick(function () {
|
|
||||||
assert.ifError(err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
setUp: function (done) {
|
|
||||||
// Clear database
|
|
||||||
helpers.resetData().then(function () {
|
|
||||||
done();
|
|
||||||
}, fail);
|
|
||||||
},
|
|
||||||
|
|
||||||
'settings:browse': function (test) {
|
|
||||||
test.expect(1);
|
|
||||||
api.settings.browse().then(function (settings) {
|
|
||||||
settings = _.map(settings.toJSON(), function (item) {
|
|
||||||
return _.omit(item, 'id', 'updated_at', 'created_at');
|
|
||||||
});
|
|
||||||
test.deepEqual(settings, fixtures.settings);
|
|
||||||
test.done();
|
|
||||||
}).then(null, fail);
|
|
||||||
},
|
|
||||||
|
|
||||||
'settings:read': function (test) {
|
|
||||||
api.settings.read('title', function (setting) {
|
|
||||||
test.done();
|
|
||||||
}).then(null, fail);
|
|
||||||
},
|
|
||||||
|
|
||||||
'settings:edit': function (test) {
|
|
||||||
test.expect(2);
|
|
||||||
api.settings.edit('title', "Jenna O'Neil").then(function (title) {
|
|
||||||
title = title.toJSON();
|
|
||||||
test.equal(title.key, 'title');
|
|
||||||
test.equal(title.value, "Jenna O'Neil");
|
|
||||||
test.done();
|
|
||||||
}).then(null, fail);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}());
|
|
|
@ -1,16 +0,0 @@
|
||||||
/*global require, module */
|
|
||||||
(function () {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var DataProvider = require('../../shared/models/dataProvider.json');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
'singleton': function (test) {
|
|
||||||
var provider1 = new DataProvider(),
|
|
||||||
provider2 = new DataProvider();
|
|
||||||
|
|
||||||
test.equal(provider1, provider2);
|
|
||||||
test.done();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}());
|
|
|
@ -1,16 +0,0 @@
|
||||||
/*global require, module */
|
|
||||||
(function () {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var Ghost = require('../../ghost');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
'singleton': function (test) {
|
|
||||||
var ghost1 = new Ghost(),
|
|
||||||
ghost2 = new Ghost();
|
|
||||||
|
|
||||||
test.equal(ghost1, ghost2);
|
|
||||||
test.done();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}());
|
|
|
@ -23,8 +23,6 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"grunt": "~0.4.1",
|
"grunt": "~0.4.1",
|
||||||
"grunt-contrib-nodeunit": "0.1.x",
|
|
||||||
"nodeunit": "0.8.x",
|
|
||||||
"grunt-jslint": "0.2.x",
|
"grunt-jslint": "0.2.x",
|
||||||
"should": "~1.2.2",
|
"should": "~1.2.2",
|
||||||
"grunt-mocha-test": "~0.4.0",
|
"grunt-mocha-test": "~0.4.0",
|
||||||
|
|
Loading…
Add table
Reference in a new issue