不要怂,就是干,撸起袖子干!

Commit 94f5e189 by Jan Aagaard Meier

Add chai missing assertions to dev deps and change some assertions not.to.be.def…

…ined -> to.be.undefined
1 parent fb94baeb
......@@ -46,6 +46,7 @@
"chai": "^2.1.2",
"chai-as-promised": "^4.3.0",
"chai-datetime": "~1.3.0",
"chai-missing-assertions": "^1.0.0",
"chai-spies": "~0.5.1",
"coffee-script": "~1.7.1",
"commander": "^2.6.0",
......
......@@ -216,7 +216,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
}).then(function(projects) {
expect(projects).to.have.length(1);
var project = projects[0];
expect(project.ProjectUsers).to.be.defined;
expect(project.ProjectUsers).to.be.ok;
expect(project.status).not.to.exist;
expect(project.ProjectUsers.status).to.equal('active');
});
......@@ -1086,7 +1086,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
);
}).spread(function(user, projects) {
var project = projects[0];
expect(project).to.be.defined;
expect(project).to.be.ok;
return project.destroy().return (user);
}).then(function(user) {
return self.User.find({
......@@ -1097,7 +1097,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
var projects = user.Projects
, project = projects[0];
expect(project).to.be.defined;
expect(project).to.be.ok;
});
});
......@@ -1117,7 +1117,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
}).then(function(projects) {
var project = projects[0];
expect(project).to.be.defined;
expect(project).to.be.ok;
return self.user.removeProject(project).on('sql', function(sql) {
}).return (project);
}).then(function(project) {
......@@ -1180,13 +1180,13 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
});
}).then(function(groups) {
var group = groups[0];
expect(group).to.be.defined;
expect(group).to.be.ok;
var user = group.Users[0];
expect(user).to.be.defined;
expect(user).to.be.ok;
var project = user.Projects[0];
expect(project).to.be.defined;
expect(project).to.be.ok;
expect(project.name).to.equal('Good Will Hunting');
});
});
......@@ -1307,7 +1307,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
}).then(function(projects) {
var project = projects[0];
expect(project.UserProjects).to.be.defined;
expect(project.UserProjects).to.be.ok;
expect(project.status).not.to.exist;
expect(project.UserProjects.status).to.equal('active');
expect(project.UserProjects.data).to.equal(42);
......@@ -1325,7 +1325,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
}).then(function(projects) {
var project = projects[0];
expect(project.UserProjects).to.be.defined;
expect(project.UserProjects).to.be.ok;
expect(project.status).not.to.exist;
expect(project.UserProjects.status).to.equal('active');
expect(project.UserProjects.data).not.to.exist;
......@@ -1877,7 +1877,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
var UserProjects = User.belongsToMany(Project, { foreignKey: { name: 'user_id', defaultValue: 42 }});
expect(UserProjects.through.model.rawAttributes.user_id).to.be.defined;
expect(UserProjects.through.model.rawAttributes.user_id).to.be.ok;
expect(UserProjects.through.model.rawAttributes.user_id.references).to.equal(User.getTableName());
expect(UserProjects.through.model.rawAttributes.user_id.referencesKey).to.equal('uid');
expect(UserProjects.through.model.rawAttributes.user_id.defaultValue).to.equal(42);
......
......@@ -639,7 +639,7 @@ describe(Support.getTestDialectTeaser('BelongsTo'), function() {
}
});
expect(Task.rawAttributes.uid).to.be.defined;
expect(Task.rawAttributes.uid).to.be.ok;
expect(Task.rawAttributes.uid.allowNull).to.be.false;
expect(Task.rawAttributes.uid.references).to.equal(User.getTableName());
expect(Task.rawAttributes.uid.referencesKey).to.equal('id');
......@@ -661,7 +661,7 @@ describe(Support.getTestDialectTeaser('BelongsTo'), function() {
Profile.belongsTo(User, { foreignKey: Profile.rawAttributes.user_id});
expect(Profile.rawAttributes.user_id).to.be.defined;
expect(Profile.rawAttributes.user_id).to.be.ok;
expect(Profile.rawAttributes.user_id.references).to.equal(User.getTableName());
expect(Profile.rawAttributes.user_id.referencesKey).to.equal('uid');
expect(Profile.rawAttributes.user_id.allowNull).to.be.false;
......@@ -678,7 +678,7 @@ describe(Support.getTestDialectTeaser('BelongsTo'), function() {
Task.belongsTo(Project, { foreignKey: { allowNull: true }});
expect(Task.rawAttributes.projectId).to.be.defined;
expect(Task.rawAttributes.projectId).to.be.ok;
expect(Task.rawAttributes.projectId.defaultValue).to.equal(42);
expect(Task.rawAttributes.projectId.allowNull).to.be.ok;
});
......
......@@ -945,7 +945,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
}).then(function(projects) {
expect(projects).to.have.length(1);
var project = projects[0];
expect(project.ProjectUsers).to.be.defined;
expect(project.ProjectUsers).to.be.ok;
expect(project.status).not.to.exist;
expect(project.ProjectUsers.status).to.equal('active');
});
......@@ -1613,7 +1613,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
);
}).spread(function(user, projects) {
var project = projects[0];
expect(project).to.be.defined;
expect(project).to.be.ok;
return project.destroy().return (user);
}).then(function(user) {
return self.User.find({
......@@ -1624,7 +1624,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
var projects = user.Projects
, project = projects[0];
expect(project).to.be.defined;
expect(project).to.be.ok;
});
});
......@@ -1644,7 +1644,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
}).then(function(projects) {
var project = projects[0];
expect(project).to.be.defined;
expect(project).to.be.ok;
return self.user.removeProject(project).return(project);
}).then(function(project) {
return self.user.setProjects([project]);
......@@ -1664,7 +1664,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
return user.getPuppies().then(function(puppies) {
var puppy = puppies[0];
expect(puppy).to.be.defined;
expect(puppy).to.be.ok;
expect(puppy.rawAttributes.userId).to.be.ok;
expect(puppy.userId).to.equal(user.id);
});
......@@ -1718,13 +1718,13 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
});
}).then(function(groups) {
var group = groups[0];
expect(group).to.be.defined;
expect(group).to.be.ok;
var user = group.Users[0];
expect(user).to.be.defined;
expect(user).to.be.ok;
var project = user.Projects[0];
expect(project).to.be.defined;
expect(project).to.be.ok;
expect(project.name).to.equal('Good Will Hunting');
});
});
......@@ -1845,7 +1845,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
}).then(function(projects) {
var project = projects[0];
expect(project.UserProjects).to.be.defined;
expect(project.UserProjects).to.be.ok;
expect(project.status).not.to.exist;
expect(project.UserProjects.status).to.equal('active');
expect(project.UserProjects.data).to.equal(42);
......@@ -1863,7 +1863,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
}).then(function(projects) {
var project = projects[0];
expect(project.UserProjects).to.be.defined;
expect(project.UserProjects).to.be.ok;
expect(project.status).not.to.exist;
expect(project.UserProjects.status).to.equal('active');
expect(project.UserProjects.data).not.to.exist;
......@@ -2621,7 +2621,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
}
});
expect(Task.rawAttributes.uid).to.be.defined;
expect(Task.rawAttributes.uid).to.be.ok;
expect(Task.rawAttributes.uid.allowNull).to.be.false;
expect(Task.rawAttributes.uid.references).to.equal(User.getTableName());
expect(Task.rawAttributes.uid.referencesKey).to.equal('id');
......@@ -2632,14 +2632,14 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
}
});
expect(Task.rawAttributes.uid).not.to.be.defined;
expect(Task.rawAttributes.uid).to.be.undefined;
expect(Task.associations.tasksusers.through.model.rawAttributes.taskId).to.be.defined;
expect(Task.associations.tasksusers.through.model.rawAttributes.taskId).to.be.ok;
expect(Task.associations.tasksusers.through.model.rawAttributes.taskId.allowNull).to.be.false;
expect(Task.associations.tasksusers.through.model.rawAttributes.taskId.references).to.equal(Task.getTableName());
expect(Task.associations.tasksusers.through.model.rawAttributes.taskId.referencesKey).to.equal('id');
expect(Task.associations.tasksusers.through.model.rawAttributes.uid).to.be.defined;
expect(Task.associations.tasksusers.through.model.rawAttributes.uid).to.be.ok;
expect(Task.associations.tasksusers.through.model.rawAttributes.uid.allowNull).to.be.false;
expect(Task.associations.tasksusers.through.model.rawAttributes.uid.references).to.equal(User.getTableName());
expect(Task.associations.tasksusers.through.model.rawAttributes.uid.referencesKey).to.equal('id');
......@@ -2661,7 +2661,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
User.hasMany(Project, { foreignKey: Project.rawAttributes.user_id});
expect(Project.rawAttributes.user_id).to.be.defined;
expect(Project.rawAttributes.user_id).to.be.ok;
expect(Project.rawAttributes.user_id.references).to.equal(User.getTableName());
expect(Project.rawAttributes.user_id.referencesKey).to.equal('uid');
expect(Project.rawAttributes.user_id.defaultValue).to.equal(42);
......@@ -2678,7 +2678,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
User.hasMany(Task, { foreignKey: { allowNull: true }});
expect(Task.rawAttributes.userId).to.be.defined;
expect(Task.rawAttributes.userId).to.be.ok;
expect(Task.rawAttributes.userId.defaultValue).to.equal(42);
expect(Task.rawAttributes.userId.allowNull).to.be.ok;
});
......
......@@ -534,7 +534,7 @@ describe(Support.getTestDialectTeaser('HasOne'), function() {
}
});
expect(Profile.rawAttributes.uid).to.be.defined;
expect(Profile.rawAttributes.uid).to.be.ok;
expect(Profile.rawAttributes.uid.references).to.equal(User.getTableName());
expect(Profile.rawAttributes.uid.referencesKey).to.equal('id');
expect(Profile.rawAttributes.uid.allowNull).to.be.false;
......@@ -548,7 +548,7 @@ describe(Support.getTestDialectTeaser('HasOne'), function() {
}
});
expect(Profile.rawAttributes.uid).to.be.defined;
expect(Profile.rawAttributes.uid).to.be.ok;
expect(Profile.rawAttributes.uid.references).to.equal(User.getTableName());
expect(Profile.rawAttributes.uid.referencesKey).to.equal('id');
expect(Profile.rawAttributes.uid.allowNull).to.be.false;
......@@ -570,7 +570,7 @@ describe(Support.getTestDialectTeaser('HasOne'), function() {
User.hasOne(Profile, { foreignKey: Profile.rawAttributes.user_id});
expect(Profile.rawAttributes.user_id).to.be.defined;
expect(Profile.rawAttributes.user_id).to.be.ok;
expect(Profile.rawAttributes.user_id.references).to.equal(User.getTableName());
expect(Profile.rawAttributes.user_id.referencesKey).to.equal('uid');
expect(Profile.rawAttributes.user_id.allowNull).to.be.false;
......@@ -592,7 +592,7 @@ describe(Support.getTestDialectTeaser('HasOne'), function() {
User.hasOne(Project, { foreignKey: { allowNull: false }});
expect(Project.rawAttributes.userUid).to.be.defined;
expect(Project.rawAttributes.userUid).to.be.ok;
expect(Project.rawAttributes.userUid.allowNull).to.be.false;
expect(Project.rawAttributes.userUid.references).to.equal(User.getTableName());
expect(Project.rawAttributes.userUid.referencesKey).to.equal('uid');
......
......@@ -547,7 +547,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), function() {
var successfulUser = User.build({ name: '2' });
return successfulUser.validate().then(function(err) {
expect(err).not.to.be.defined;
expect(err).to.be.undefined;
});
});
});
......@@ -576,7 +576,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), function() {
expect(error.get('name')[0].message).to.equal('Invalid username');
return User.build({ name: 'no error' }).validate().then(function(errors) {
expect(errors).not.to.be.defined;
expect(errors).to.be.undefined;
});
});
});
......
......@@ -2365,7 +2365,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
if (dialect !== 'sqlite' && current.dialect.supports.transactions) {
it('supports multiple async transactions', function() {
this.timeout(25000);
this.timeout(50000);
var self = this;
return Support.prepareTransactionTest(this.sequelize).bind({}).then(function(sequelize) {
var User = sequelize.define('User', { username: Sequelize.STRING });
......
......@@ -43,7 +43,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
it('works with upsert on id', function() {
return this.User.upsert({ id: 42, username: 'john' }).bind(this).then(function(created) {
if (dialect === 'sqlite') {
expect(created).not.to.be.defined;
expect(created).to.be.undefined;
} else {
expect(created).to.be.ok;
}
......@@ -53,14 +53,14 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
}).then(function(created) {
if (dialect === 'sqlite') {
expect(created).not.to.be.defined;
expect(created).to.be.undefined;
} else {
expect(created).not.to.be.ok;
}
return this.User.find(42);
}).then(function(user) {
expect(user.createdAt).to.be.defined;
expect(user.createdAt).to.be.ok;
expect(user.username).to.equal('doe');
expect(user.updatedAt).to.be.afterTime(user.createdAt);
});
......@@ -69,7 +69,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
it('works with upsert on a composite key', function() {
return this.User.upsert({ foo: 'baz', bar: 19, username: 'john' }).bind(this).then(function(created) {
if (dialect === 'sqlite') {
expect(created).not.to.be.defined;
expect(created).to.be.undefined;
} else {
expect(created).to.be.ok;
}
......@@ -79,14 +79,14 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
}).then(function(created) {
if (dialect === 'sqlite') {
expect(created).not.to.be.defined;
expect(created).to.be.undefined;
} else {
expect(created).not.to.be.ok;
}
return this.User.find({ where: { foo: 'baz', bar: 19 }});
}).then(function(user) {
expect(user.createdAt).to.be.defined;
expect(user.createdAt).to.be.ok;
expect(user.username).to.equal('doe');
expect(user.updatedAt).to.be.afterTime(user.createdAt);
});
......@@ -113,8 +113,8 @@ describe(Support.getTestDialectTeaser('Model'), function() {
]);
}).spread(function(created1, created2) {
if (dialect === 'sqlite') {
expect(created1).not.to.be.defined;
expect(created2).not.to.be.defined;
expect(created1).to.be.undefined;
expect(created2).to.be.undefined;
} else {
expect(created1).to.be.ok;
expect(created2).to.be.ok;
......@@ -126,21 +126,21 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
}).then(function(created) {
if (dialect === 'sqlite') {
expect(created).not.to.be.defined;
expect(created).to.be.undefined;
} else {
expect(created).not.to.be.ok;
}
return User.find({ where: { a: 'a', b: 'b' }});
}).then(function (user1) {
expect(user1.createdAt).to.be.defined;
expect(user1.createdAt).to.be.ok;
expect(user1.username).to.equal('doe');
expect(user1.updatedAt).to.be.afterTime(user1.createdAt);
return User.find({ where: { a: 'a', b: 'a' }});
}).then(function (user2) {
// The second one should not be updated
expect(user2.createdAt).to.be.defined;
expect(user2.createdAt).to.be.ok;
expect(user2.username).to.equal('curt');
expect(user2.updatedAt).to.equalTime(user2.createdAt);
});
......@@ -162,7 +162,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
it('works with BLOBs', function () {
return this.User.upsert({ id: 42, username: 'john', blob: new Buffer('kaj') }).bind(this).then(function(created) {
if (dialect === 'sqlite') {
expect(created).not.to.be.defined;
expect(created).to.be.undefined;
} else {
expect(created).to.be.ok;
}
......@@ -172,14 +172,14 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
}).then(function(created) {
if (dialect === 'sqlite') {
expect(created).not.to.be.defined;
expect(created).to.be.undefined;
} else {
expect(created).not.to.be.ok;
}
return this.User.find(42);
}).then(function(user) {
expect(user.createdAt).to.be.defined;
expect(user.createdAt).to.be.ok;
expect(user.username).to.equal('doe');
expect(user.blob.toString()).to.equal('andrea');
expect(user.updatedAt).to.be.afterTime(user.createdAt);
......@@ -189,7 +189,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
it('works with .field', function () {
return this.User.upsert({ id: 42, baz: 'foo' }).bind(this).then(function(created) {
if (dialect === 'sqlite') {
expect(created).not.to.be.defined;
expect(created).to.be.undefined;
} else {
expect(created).to.be.ok;
}
......@@ -199,7 +199,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
}).then(function(created) {
if (dialect === 'sqlite') {
expect(created).not.to.be.defined;
expect(created).to.be.undefined;
} else {
expect(created).not.to.be.ok;
}
......
......@@ -139,7 +139,7 @@ describe(Support.getTestDialectTeaser('Sequelize#transaction'), function() {
return self.Model.create({ name: 'omnom' }, { transaction: t1 }).then(function(m1) {
return Promise.all([
self.Model.create({ name: 'omnom' }, { transaction: t2 }).catch(function(err) {
expect(err).to.be.defined;
expect(err).to.be.ok;
return t2.rollback();
}),
Promise.delay(100).then(function() {
......
......@@ -8,9 +8,10 @@ var fs = require('fs')
, Config = require(__dirname + '/config/config')
, chai = require('chai')
, expect = chai.expect
, chaiAsPromised = require('chai-as-promised');
, chaiAsPromised = require('chai-as-promised')
, missingAssertions = require('chai-missing-assertions');
chai.use(chaiAsPromised);
chai.use(missingAssertions);
// Make sure errors get thrown when testing
Sequelize.Promise.onPossiblyUnhandledRejection(function(e, promise) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!