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

Commit 416a7cee by papb

test(model): fix flaky timestamp test

1 parent 2fe980e2
Showing with 20 additions and 3 deletions
......@@ -9,6 +9,7 @@ const chai = require('chai'),
dialect = Support.getTestDialect(),
Op = Sequelize.Op,
_ = require('lodash'),
delay = require('delay'),
assert = require('assert'),
current = Support.sequelize,
pTimeout = require('p-timeout');
......@@ -724,12 +725,28 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
await this.sequelize.sync({ force: true });
const user = await User.create({});
const user1 = await User.create({});
await delay(10);
const user2 = await User.create({});
for (const user in [user1, user2]) {
expect(user).to.be.ok;
expect(user.created_time).to.be.ok;
expect(user.updated_time).to.be.ok;
expect(user.created_time.getMilliseconds()).not.to.equal(0);
expect(user.updated_time.getMilliseconds()).not.to.equal(0);
}
// Timestamps should have milliseconds. However, there is a small chance that
// it really is 0 for one of them, by coincidence. So we check twice with two
// users created almost at the same time.
expect([
user1.created_time.getMilliseconds(),
user2.created_time.getMilliseconds()
]).not.to.deep.equal([0, 0]);
expect([
user1.updated_time.getMilliseconds(),
user2.updated_time.getMilliseconds()
]).not.to.deep.equal([0, 0]);
});
it('works with custom timestamps and underscored', async function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!