Merge pull request #251 from ErisDS/test-cleanup

Test fixes & cleanup
This commit is contained in:
Hannah Wolfe 2013-07-10 16:16:17 -07:00
commit 1a99aa8c6f
10 changed files with 35 additions and 41 deletions

View File

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

View File

@ -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 () {
@ -197,6 +197,6 @@ describe('Post Model', function () {
paginationResult.pages.should.equal(11);
done();
}).then(null, done);
}, done);
});
});

View File

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

View File

@ -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;
@ -17,7 +15,7 @@ describe('User Model', function () {
return when(helpers.insertDefaultUser());
}).then(function (results) {
done();
});
}, done);
});
it('can add first', function (done) {
@ -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);
@ -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();
});
});
@ -58,7 +57,7 @@ describe('User Model', function () {
done();
}).then(null, done);
}, done);
});
it('can read', function (done) {
@ -82,7 +81,7 @@ describe('User Model', function () {
done();
}).then(null, done);
}, done);
});
@ -107,7 +106,7 @@ describe('User Model', function () {
done();
}).then(null, done);
}, done);
});
it("can get effective permissions", function (done) {
@ -117,7 +116,7 @@ describe('User Model', function () {
effectivePermissions.length.should.be.above(0);
done();
}, errors.logError);
}, done);
});
it('can delete', function (done) {
@ -153,6 +152,6 @@ describe('User Model', function () {
hasDeletedId.should.equal(false);
done();
}).then(null, done);
}, done);
});
});

View File

@ -29,7 +29,7 @@ describe("Export", function () {
exportStub.restore();
done();
}, errors.throwError);
}, done);
});
describe("001", function () {
@ -52,9 +52,7 @@ describe("Export", function () {
});
done();
}, function () {
console.log("Error in exporter");
});
}, done);
});
});
});

View File

@ -38,7 +38,7 @@ describe("Ghost API", function () {
ghost.dataProvider = oldDataProvider;
done();
}).then(null, done);
}, done);
});

View File

@ -78,10 +78,7 @@ helpers = {
u_promises.push(knex('users').insert(users));
u_promises.push(knex('roles_users').insert(userRoles));
return when.all(u_promises).then(function (results) {
return;
});
return when.all(u_promises);
}
};

View File

@ -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) {
@ -32,7 +33,7 @@ describe("Import", function () {
importStub.restore();
done();
}, errors.logAndThrowError);
}, done);
});
describe("001", function () {
@ -72,7 +73,7 @@ describe("Import", function () {
importedData[2].length.should.equal(exportData.data.settings.length);
done();
}).otherwise(errors.logAndThrowError);
}, done);
});
});
});

View File

@ -18,7 +18,7 @@ describe('permissions', function () {
return helpers.insertDefaultUser();
}).then(function (results) {
done();
}).otherwise(errors.logAndThrowError);
}, done);
});
var testPerms = [

View File

@ -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"
}