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

Commit 9e081439 by Ruben Bridgewater

Refactor more tests

1 parent e45a8d3a
...@@ -359,7 +359,7 @@ describe(Support.getTestDialectTeaser('Instance'), function() { ...@@ -359,7 +359,7 @@ describe(Support.getTestDialectTeaser('Instance'), function() {
, oldUpdatedAt = user.updatedAt , oldUpdatedAt = user.updatedAt
, oldIdentifier = user.identifier; , oldIdentifier = user.identifier;
return Promise.delay(1000).then(function() { return this.sequelize.Promise.delay(1000).then(function() {
return user.update({ return user.update({
name: 'foobar', name: 'foobar',
createdAt: new Date(2000, 1, 1), createdAt: new Date(2000, 1, 1),
......
...@@ -295,7 +295,7 @@ describe(Support.getTestDialectTeaser('DAO'), function() { ...@@ -295,7 +295,7 @@ describe(Support.getTestDialectTeaser('DAO'), function() {
expect(product.toJSON()).to.deep.equal({withTaxes: 1250, price: 1000, id: null}); expect(product.toJSON()).to.deep.equal({withTaxes: 1250, price: 1000, id: null});
}); });
it('should work with save', function(done) { it('should work with save', function() {
var Contact = this.sequelize.define('Contact', { var Contact = this.sequelize.define('Contact', {
first: { type: Sequelize.STRING }, first: { type: Sequelize.STRING },
last: { type: Sequelize.STRING }, last: { type: Sequelize.STRING },
...@@ -311,7 +311,7 @@ describe(Support.getTestDialectTeaser('DAO'), function() { ...@@ -311,7 +311,7 @@ describe(Support.getTestDialectTeaser('DAO'), function() {
} }
}); });
this.sequelize.sync().done(function() { return this.sequelize.sync().then(function() {
var contact = Contact.build({ var contact = Contact.build({
first: 'My', first: 'My',
last: 'Name', last: 'Name',
...@@ -319,10 +319,8 @@ describe(Support.getTestDialectTeaser('DAO'), function() { ...@@ -319,10 +319,8 @@ describe(Support.getTestDialectTeaser('DAO'), function() {
}); });
expect(contact.get('tags')).to.deep.equal(['yes', 'no']); expect(contact.get('tags')).to.deep.equal(['yes', 'no']);
contact.save().done(function(err, me) { return contact.save().then(function(me) {
expect(err).not.to.be.ok;
expect(me.get('tags')).to.deep.equal(['yes', 'no']); expect(me.get('tags')).to.deep.equal(['yes', 'no']);
done();
}); });
}); });
}); });
...@@ -380,18 +378,16 @@ describe(Support.getTestDialectTeaser('DAO'), function() { ...@@ -380,18 +378,16 @@ describe(Support.getTestDialectTeaser('DAO'), function() {
}); });
describe('changed', function() { describe('changed', function() {
it('should return false if object was built from database', function(done) { it('should return false if object was built from database', function() {
var User = this.sequelize.define('User', { var User = this.sequelize.define('User', {
name: {type: DataTypes.STRING} name: {type: DataTypes.STRING}
}); });
User.sync().done(function() { return User.sync().then(function() {
User.create({name: 'Jan Meier'}).done(function(err, user) { return User.create({name: 'Jan Meier'}).then(function(user) {
expect(err).not.to.be.ok;
expect(user.changed('name')).to.be.false; expect(user.changed('name')).to.be.false;
expect(user.changed()).not.to.be.ok; expect(user.changed()).not.to.be.ok;
expect(user.isDirty).to.be.false; expect(user.isDirty).to.be.false;
done();
}); });
}); });
}); });
...@@ -410,12 +406,12 @@ describe(Support.getTestDialectTeaser('DAO'), function() { ...@@ -410,12 +406,12 @@ describe(Support.getTestDialectTeaser('DAO'), function() {
expect(user.isDirty).to.be.true; expect(user.isDirty).to.be.true;
}); });
it('should return false immediately after saving', function(done) { it('should return false immediately after saving', function() {
var User = this.sequelize.define('User', { var User = this.sequelize.define('User', {
name: {type: DataTypes.STRING} name: {type: DataTypes.STRING}
}); });
User.sync().done(function() { return User.sync().then(function() {
var user = User.build({ var user = User.build({
name: 'Jan Meier' name: 'Jan Meier'
}); });
...@@ -424,12 +420,10 @@ describe(Support.getTestDialectTeaser('DAO'), function() { ...@@ -424,12 +420,10 @@ describe(Support.getTestDialectTeaser('DAO'), function() {
expect(user.changed()).to.be.ok; expect(user.changed()).to.be.ok;
expect(user.isDirty).to.be.true; expect(user.isDirty).to.be.true;
user.save().done(function(err) { return user.save().then(function() {
expect(err).not.to.be.ok;
expect(user.changed('name')).to.be.false; expect(user.changed('name')).to.be.false;
expect(user.changed()).not.to.be.ok; expect(user.changed()).not.to.be.ok;
expect(user.isDirty).to.be.false; expect(user.isDirty).to.be.false;
done();
}); });
}); });
}); });
...@@ -472,7 +466,6 @@ describe(Support.getTestDialectTeaser('DAO'), function() { ...@@ -472,7 +466,6 @@ describe(Support.getTestDialectTeaser('DAO'), function() {
expect(changed).to.be.ok; expect(changed).to.be.ok;
expect(changed.length).to.be.ok; expect(changed.length).to.be.ok;
expect(changed.indexOf('name') > -1).to.be.ok; expect(changed.indexOf('name') > -1).to.be.ok;
expect(user.changed()).not.to.be.ok; expect(user.changed()).not.to.be.ok;
}); });
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!