0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Test cleanup

- redoing test failures with .then(null, done) so that any errors which happen in the previous then are properly caught.
This commit is contained in:
Hannah Wolfe 2013-07-11 13:50:31 +01:00
parent 20c768e718
commit 5948a3f246
9 changed files with 48 additions and 52 deletions

View file

@ -23,7 +23,7 @@ describe("Role Model", function () {
foundRoles.models.length.should.be.above(0);
done();
}, done);
}).then(null, done);
});
it("can read roles", function (done) {
@ -31,7 +31,7 @@ describe("Role Model", function () {
should.exist(foundRole);
done();
}, done);
}).then(null, done);
});
it("can edit roles", function (done) {
@ -47,7 +47,7 @@ describe("Role Model", function () {
updatedRole.get("name").should.equal("updated");
done();
}, done);
}).then(null, done);
});
it("can add roles", function (done) {
@ -63,7 +63,7 @@ describe("Role Model", function () {
createdRole.attributes.description.should.equal(newRole.description);
done();
}, done);
}).then(null, done);
});
it("can delete roles", function (done) {
@ -81,7 +81,7 @@ describe("Role Model", function () {
hasRemovedId.should.equal(false);
done();
}, done);
}).then(null, done);
});
});
@ -104,7 +104,7 @@ describe("Permission Model", function () {
foundPermissions.models.length.should.be.above(0);
done();
}, done);
}).then(null, done);
});
it("can read permissions", function (done) {
@ -112,7 +112,7 @@ describe("Permission Model", function () {
should.exist(foundPermission);
done();
}, done);
}).then(null, done);
});
it("can edit permissions", function (done) {
@ -128,7 +128,7 @@ describe("Permission Model", function () {
updatedPermission.get("name").should.equal("updated");
done();
}, done);
}).then(null, done);
});
it("can add permissions", function (done) {
@ -142,7 +142,7 @@ describe("Permission Model", function () {
createdPerm.attributes.name.should.equal(newPerm.name);
done();
}, done);
}).then(null, done);
});
it("can delete permissions", function (done) {
@ -160,6 +160,6 @@ describe("Permission Model", function () {
hasRemovedId.should.equal(false);
done();
}, done);
}).then(null, done);
});
});

View file

@ -118,7 +118,7 @@ describe('Post Model', function () {
secondPost.get('content').should.equal("Test Content 2");
done();
}).otherwise(done);
}).then(null, done);
});
@ -133,7 +133,7 @@ describe('Post Model', function () {
createdPost.get('slug').should.equal('apprehensive-titles-have-too-many-spaces');
done();
});
}).then(null, done);
});
it('can delete', function (done) {
@ -197,6 +197,6 @@ describe('Post Model', function () {
paginationResult.pages.should.equal(11);
done();
}, done);
}).then(null, done);
});
});

View file

@ -22,7 +22,7 @@ describe('Settings Model', function () {
results.length.should.be.above(0);
done();
}, done);
}).then(null, done);
});
it('can read', function (done) {
@ -46,7 +46,7 @@ describe('Settings Model', function () {
done();
}, done);
}).then(null, done);
});
it('can edit single', function (done) {
@ -79,7 +79,7 @@ describe('Settings Model', function () {
done();
}, done);
}).then(null, done);
});
it('can edit multiple', function (done) {
@ -121,7 +121,7 @@ describe('Settings Model', function () {
done();
}, done);
}).then(null, done);
});
it('can add', function (done) {
@ -139,7 +139,7 @@ describe('Settings Model', function () {
createdSetting.attributes.type.should.equal("general");
done();
}, done);
}).then(null, done);
});
it('can delete', function (done) {
@ -173,6 +173,6 @@ describe('Settings Model', function () {
done();
}, done);
}).then(null, done);
});
});

View file

@ -11,9 +11,9 @@ describe('User Model', function () {
var UserModel = Models.User;
beforeEach(function (done) {
helpers.resetData().then(function (result) {
helpers.resetData().then(function () {
return when(helpers.insertDefaultUser());
}).then(function (results) {
}).then(function () {
done();
}, done);
});
@ -24,7 +24,7 @@ describe('User Model', function () {
email_address: "test@test1.com"
};
helpers.resetData().then(function (result) {
helpers.resetData().then(function () {
UserModel.add(userData).then(function (createdUser) {
should.exist(createdUser);
createdUser.has('uuid').should.equal(true);
@ -32,7 +32,7 @@ describe('User Model', function () {
createdUser.attributes.email_address.should.eql(userData.email_address, "email address corred");
done();
}, done);
}).then(null, done);
});
});
@ -45,7 +45,7 @@ describe('User Model', function () {
return UserModel.add(userData).then(done, function (failure) {
failure.message.should.eql('A user is already registered. Only one user for now!');
done();
});
}).then(null, done);
});
it('can browse', function (done) {
@ -57,7 +57,7 @@ describe('User Model', function () {
done();
}, done);
}).then(null, done);
});
it('can read', function (done) {
@ -81,7 +81,7 @@ describe('User Model', function () {
done();
}, done);
}).then(null, done);
});
@ -106,7 +106,7 @@ describe('User Model', function () {
done();
}, done);
}).then(null, done);
});
it("can get effective permissions", function (done) {
@ -116,7 +116,7 @@ describe('User Model', function () {
effectivePermissions.length.should.be.above(0);
done();
}, done);
}).then(null, done);
});
it('can delete', function (done) {
@ -152,6 +152,6 @@ describe('User Model', function () {
hasDeletedId.should.equal(false);
done();
}, done);
}).then(null, done);
});
});

View file

@ -29,7 +29,7 @@ describe("Export", function () {
exportStub.restore();
done();
}, done);
}).then(null, done);
});
describe("001", function () {
@ -52,7 +52,7 @@ describe("Export", function () {
});
done();
}, done);
}).then(null, done);
});
});
});

View file

@ -49,7 +49,7 @@ describe('Core Helpers', function () {
compileSpy.restore();
done();
}, done);
}).then(null, done);
});
});
});

View file

@ -45,7 +45,7 @@ describe("Ghost API", function () {
ghost.dataProvider = oldDataProvider;
done();
}, done);
}).then(null, done);
});
@ -107,7 +107,7 @@ describe("Ghost API", function () {
templateFn().should.equal('<h1>HelloWorld</h1>');
done();
}, done);
}).then(null, done);
});
it("loads templates for helpers", function (done) {
@ -133,6 +133,6 @@ describe("Ghost API", function () {
compileSpy.restore();
done();
}, done);
}).then(null, done);
});
});

View file

@ -33,7 +33,7 @@ describe("Import", function () {
importStub.restore();
done();
}, done);
}).then(null, done);
});
describe("001", function () {
@ -56,7 +56,7 @@ describe("Import", function () {
return when.all(truncateOps);
}).then(function () {
return importer("001", exportData);
}).then(function (importResult) {
}).then(function () {
// Grab the data from tables
return when.all([
knex("users").select(),
@ -73,7 +73,7 @@ describe("Import", function () {
importedData[2].length.should.equal(exportData.data.settings.length);
done();
}, done);
}).then(null, done);
});
});
});

View file

@ -14,9 +14,9 @@ var _ = require("underscore"),
describe('permissions', function () {
beforeEach(function (done) {
helpers.resetData().then(function (result) {
helpers.resetData().then(function () {
return helpers.insertDefaultUser();
}).then(function (results) {
}).then(function () {
done();
}, done);
});
@ -82,7 +82,7 @@ describe('permissions', function () {
actionsMap.should.equal(permissions.actionsMap);
done();
}, errors.throwError);
}).then(null, done);
});
it('can add user to role', function (done) {
@ -111,7 +111,7 @@ describe('permissions', function () {
updatedUser.related('roles').length.should.equal(existingUserRoles + 1);
done();
});
}).then(null, done);
});
it('can add user permissions', function (done) {
@ -135,7 +135,7 @@ describe('permissions', function () {
updatedUser.related('permissions').length.should.equal(1);
done();
});
}).then(null, done);
});
it('can add role permissions', function (done) {
@ -170,7 +170,7 @@ describe('permissions', function () {
updatedRole.related('permissions').length.should.equal(1);
done();
});
}).then(null, done);
});
it('does not allow edit post without permission', function (done) {
@ -193,9 +193,7 @@ describe('permissions', function () {
})
.then(function () {
errors.logError(new Error("Allowed edit post without permission"));
}, function () {
done();
});
}, done);
});
it('allows edit post with permission', function (done) {
@ -235,9 +233,7 @@ describe('permissions', function () {
})
.then(function () {
done();
}, function () {
errors.logError(new Error("Did not allow edit post with permission"));
});
}, done);
});
it('can use permissable function on Model to allow something', function (done) {
@ -246,8 +242,6 @@ describe('permissions', function () {
return when.resolve();
});
// createTestUser()
UserProvider.browse()
.then(function (foundUser) {
@ -265,6 +259,8 @@ describe('permissions', function () {
.otherwise(function () {
permissableStub.restore();
errors.logError(new Error("Did not allow testUser"));
done();
});
});