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

You need to sign in or sign up before continuing.
Commit 466016ee by Rui Marinho

Replace sinon fake clock by promises

1 parent 45b84d31
......@@ -999,8 +999,6 @@ describe(Support.getTestDialectTeaser('Model'), function() {
{ username: 'Paul', secretValue: '42' },
{ username: 'Bob', secretValue: '43' }];
this.clock = sinon.useFakeTimers();
return this.User.bulkCreate(data).bind(this).then(function() {
return this.User.findAll({order: 'id'});
}).then(function(users) {
......@@ -1010,9 +1008,9 @@ describe(Support.getTestDialectTeaser('Model'), function() {
expect(this.updatedAt).to.equalTime(users[2].updatedAt); // All users should have the same updatedAt
// Pass the time so we can actually see a change
this.clock.tick(1000);
return this.sequelize.Promise.delay(1000).bind(this).then(function() {
return this.User.update({username: 'Bill'}, {where: {secretValue: '42'}});
});
}).then(function() {
return this.User.findAll({order: 'id'});
}).then(function(users) {
......@@ -1022,8 +1020,6 @@ describe(Support.getTestDialectTeaser('Model'), function() {
expect(users[0].updatedAt).to.be.afterTime(this.updatedAt);
expect(users[2].updatedAt).to.equalTime(this.updatedAt);
this.clock.restore();
});
});
......
......@@ -18,8 +18,6 @@ chai.config.includeStack = true;
describe(Support.getTestDialectTeaser('Model'), function() {
beforeEach(function() {
this.clock = sinon.useFakeTimers();
this.User = this.sequelize.define('user', {
username: DataTypes.STRING,
foo: {
......@@ -35,10 +33,6 @@ describe(Support.getTestDialectTeaser('Model'), function() {
return this.sequelize.sync({ force: true });
});
afterEach(function() {
this.clock.restore();
});
if (current.dialect.supports.upserts) {
describe('upsert', function() {
it('works with upsert on id', function() {
......@@ -49,8 +43,9 @@ describe(Support.getTestDialectTeaser('Model'), function() {
expect(created).to.be.ok;
}
this.clock.tick(2000); // Make sure to pass some time so updatedAt != createdAt
return this.sequelize.Promise.delay(1000).bind(this).then(function() {
return this.User.upsert({ id: 42, username: 'doe' });
});
}).then(function(created) {
if (dialect === 'sqlite') {
expect(created).not.to.be.defined;
......@@ -74,8 +69,9 @@ describe(Support.getTestDialectTeaser('Model'), function() {
expect(created).to.be.ok;
}
this.clock.tick(2000); // Make sure to pass some time so updatedAt != createdAt
return this.sequelize.Promise.delay(1000).bind(this).then(function() {
return this.User.upsert({ foo: 'baz', bar: 19, username: 'doe' });
});
}).then(function(created) {
if (dialect === 'sqlite') {
expect(created).not.to.be.defined;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!