Skip to content

Commit

Permalink
Merge pull request TryGhost#251 from ErisDS/test-cleanup
Browse files Browse the repository at this point in the history
Test fixes & cleanup
  • Loading branch information
ErisDS committed Jul 10, 2013
2 parents bdacd02 + be744c3 commit e8dfb16
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 41 deletions.
16 changes: 8 additions & 8 deletions core/test/ghost/api_permissions_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ describe("Role Model", function () {
foundRoles.models.length.should.be.above(0);

done();
}, errors.logError);
}, done);
});

it("can read roles", function (done) {
RoleModel.read({id: 1}).then(function (foundRole) {
should.exist(foundRole);

done();
}, errors.logError);
}, done);
});

it("can edit roles", function (done) {
Expand All @@ -47,7 +47,7 @@ describe("Role Model", function () {
updatedRole.get("name").should.equal("updated");

done();
}, errors.logError);
}, done);
});

it("can add roles", function (done) {
Expand Down Expand Up @@ -81,7 +81,7 @@ describe("Role Model", function () {
hasRemovedId.should.equal(false);

done();
}, errors.logError);
}, done);
});
});

Expand All @@ -104,15 +104,15 @@ describe("Permission Model", function () {
foundPermissions.models.length.should.be.above(0);

done();
}, errors.logError);
}, done);
});

it("can read permissions", function (done) {
PermissionModel.read({id: 1}).then(function (foundPermission) {
should.exist(foundPermission);

done();
}, errors.logError);
}, done);
});

it("can edit permissions", function (done) {
Expand All @@ -128,7 +128,7 @@ describe("Permission Model", function () {
updatedPermission.get("name").should.equal("updated");

done();
}, errors.logError);
}, done);
});

it("can add permissions", function (done) {
Expand Down Expand Up @@ -160,6 +160,6 @@ describe("Permission Model", function () {
hasRemovedId.should.equal(false);

done();
}, errors.logError);
}, done);
});
});
4 changes: 2 additions & 2 deletions core/test/ghost/api_posts_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ describe('Post Model', function () {
});

it('can fetch a paginated set, with various options', function (done) {
this.timeout(4000);
this.timeout(5000);

helpers.insertMorePosts().then(function () {

Expand Down Expand Up @@ -197,6 +197,6 @@ describe('Post Model', function () {
paginationResult.pages.should.equal(11);

done();
}).then(null, done);
}, done);
});
});
12 changes: 6 additions & 6 deletions core/test/ghost/api_settings_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Settings Model', function () {
results.length.should.be.above(0);

done();
}).then(null, done);
}, done);
});

it('can read', function (done) {
Expand All @@ -46,7 +46,7 @@ describe('Settings Model', function () {

done();

}).then(null, done);
}, done);
});

it('can edit single', function (done) {
Expand Down Expand Up @@ -79,7 +79,7 @@ describe('Settings Model', function () {

done();

}).then(null, done);
}, done);
});

it('can edit multiple', function (done) {
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('Settings Model', function () {

done();

}).then(null, done);
}, done);
});

it('can add', function (done) {
Expand All @@ -139,7 +139,7 @@ describe('Settings Model', function () {
createdSetting.attributes.type.should.equal("general");

done();
}).then(null, done);
}, done);
});

it('can delete', function (done) {
Expand Down Expand Up @@ -173,6 +173,6 @@ describe('Settings Model', function () {

done();

}).then(null, done);
}, done);
});
});
21 changes: 10 additions & 11 deletions core/test/ghost/api_users_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ var _ = require('underscore'),
Models = require('../../shared/models'),
when = require('when');

require('mocha-as-promised')();

describe('User Model', function () {

var UserModel = Models.User;
Expand All @@ -17,7 +15,7 @@ describe('User Model', function () {
return when(helpers.insertDefaultUser());
}).then(function (results) {
done();
});
}, done);
});

it('can add first', function (done) {
Expand All @@ -26,7 +24,7 @@ describe('User Model', function () {
email_address: "test@test1.com"
};

when(helpers.resetData()).then(function (result) {
helpers.resetData().then(function (result) {
UserModel.add(userData).then(function (createdUser) {
should.exist(createdUser);
createdUser.has('uuid').should.equal(true);
Expand All @@ -44,8 +42,9 @@ describe('User Model', function () {
email_address: "test3@test1.com"
};

return when(UserModel.add(userData)).otherwise(function (failure) {
return failure.message.should.eql('A user is already registered. Only one user for now!');
return UserModel.add(userData).then(done, function (failure) {
failure.message.should.eql('A user is already registered. Only one user for now!');
done();
});
});

Expand All @@ -58,7 +57,7 @@ describe('User Model', function () {

done();

}).then(null, done);
}, done);
});

it('can read', function (done) {
Expand All @@ -82,7 +81,7 @@ describe('User Model', function () {

done();

}).then(null, done);
}, done);

});

Expand All @@ -107,7 +106,7 @@ describe('User Model', function () {

done();

}).then(null, done);
}, done);
});

it("can get effective permissions", function (done) {
Expand All @@ -117,7 +116,7 @@ describe('User Model', function () {
effectivePermissions.length.should.be.above(0);

done();
}, errors.logError);
}, done);
});

it('can delete', function (done) {
Expand Down Expand Up @@ -153,6 +152,6 @@ describe('User Model', function () {
hasDeletedId.should.equal(false);
done();

}).then(null, done);
}, done);
});
});
6 changes: 2 additions & 4 deletions core/test/ghost/export_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("Export", function () {
exportStub.restore();

done();
}, errors.throwError);
}, done);
});

describe("001", function () {
Expand All @@ -52,9 +52,7 @@ describe("Export", function () {
});

done();
}, function () {
console.log("Error in exporter");
});
}, done);
});
});
});
2 changes: 1 addition & 1 deletion core/test/ghost/ghost_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("Ghost API", function () {
ghost.dataProvider = oldDataProvider;

done();
}).then(null, done);
}, done);

});

Expand Down
5 changes: 1 addition & 4 deletions core/test/ghost/helpers.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions core/test/ghost/import_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ var _ = require("underscore"),
describe("Import", function () {

should.exist(exporter);
should.exist(importer);

beforeEach(function (done) {
helpers.resetData().then(function () {
done();
}, errors.logAndThrowError);
}, done);
});

it("resolves 001", function (done) {
Expand All @@ -32,7 +33,7 @@ describe("Import", function () {
importStub.restore();

done();
}, errors.logAndThrowError);
}, done);
});

describe("001", function () {
Expand Down Expand Up @@ -72,7 +73,7 @@ describe("Import", function () {
importedData[2].length.should.equal(exportData.data.settings.length);

done();
}).otherwise(errors.logAndThrowError);
}, done);
});
});
});
2 changes: 1 addition & 1 deletion core/test/ghost/permissions_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('permissions', function () {
return helpers.insertDefaultUser();
}).then(function (results) {
done();
}).otherwise(errors.logAndThrowError);
}, done);
});

var testPerms = [
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"grunt-bump": "~0.0.11",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-compress": "~0.5.2",
"mocha-as-promised": "~1.4.0",
"grunt-groc": "~0.3.0",
"grunt-mocha-cli": "~1.0.6"
}
Expand Down

0 comments on commit e8dfb16

Please sign in to comment.