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

Commit b17e7d8f by Andy Edwards Committed by GitHub

test(integration/include): asyncify (#12294)

1 parent fd11d98f
...@@ -8,7 +8,7 @@ const chai = require('chai'), ...@@ -8,7 +8,7 @@ const chai = require('chai'),
describe(Support.getTestDialectTeaser('Paranoid'), () => { describe(Support.getTestDialectTeaser('Paranoid'), () => {
beforeEach(function( ) { beforeEach(async function() {
const S = this.sequelize, const S = this.sequelize,
DT = DataTypes, DT = DataTypes,
...@@ -29,7 +29,7 @@ describe(Support.getTestDialectTeaser('Paranoid'), () => { ...@@ -29,7 +29,7 @@ describe(Support.getTestDialectTeaser('Paranoid'), () => {
D.belongsToMany(A, { through: 'a_d' }); D.belongsToMany(A, { through: 'a_d' });
return S.sync({ force: true }); await S.sync({ force: true });
}); });
before(function() { before(function() {
...@@ -40,7 +40,7 @@ describe(Support.getTestDialectTeaser('Paranoid'), () => { ...@@ -40,7 +40,7 @@ describe(Support.getTestDialectTeaser('Paranoid'), () => {
this.clock.restore(); this.clock.restore();
}); });
it('paranoid with timestamps: false should be ignored / not crash', function() { it('paranoid with timestamps: false should be ignored / not crash', async function() {
const S = this.sequelize, const S = this.sequelize,
Test = S.define('Test', { Test = S.define('Test', {
name: DataTypes.STRING name: DataTypes.STRING
...@@ -49,12 +49,12 @@ describe(Support.getTestDialectTeaser('Paranoid'), () => { ...@@ -49,12 +49,12 @@ describe(Support.getTestDialectTeaser('Paranoid'), () => {
paranoid: true paranoid: true
}); });
return S.sync({ force: true }).then(() => { await S.sync({ force: true });
return Test.findByPk(1);
}); await Test.findByPk(1);
}); });
it('test if non required is marked as false', function( ) { it('test if non required is marked as false', async function() {
const A = this.A, const A = this.A,
B = this.B, B = this.B,
options = { options = {
...@@ -66,12 +66,11 @@ describe(Support.getTestDialectTeaser('Paranoid'), () => { ...@@ -66,12 +66,11 @@ describe(Support.getTestDialectTeaser('Paranoid'), () => {
] ]
}; };
return A.findOne(options).then(() => { await A.findOne(options);
expect(options.include[0].required).to.be.equal(false); expect(options.include[0].required).to.be.equal(false);
});
}); });
it('test if required is marked as true', function( ) { it('test if required is marked as true', async function() {
const A = this.A, const A = this.A,
B = this.B, B = this.B,
options = { options = {
...@@ -83,12 +82,11 @@ describe(Support.getTestDialectTeaser('Paranoid'), () => { ...@@ -83,12 +82,11 @@ describe(Support.getTestDialectTeaser('Paranoid'), () => {
] ]
}; };
return A.findOne(options).then(() => { await A.findOne(options);
expect(options.include[0].required).to.be.equal(true); expect(options.include[0].required).to.be.equal(true);
});
}); });
it('should not load paranoid, destroyed instances, with a non-paranoid parent', function() { it('should not load paranoid, destroyed instances, with a non-paranoid parent', async function() {
const X = this.sequelize.define('x', { const X = this.sequelize.define('x', {
name: DataTypes.STRING name: DataTypes.STRING
}, { }, {
...@@ -104,27 +102,26 @@ describe(Support.getTestDialectTeaser('Paranoid'), () => { ...@@ -104,27 +102,26 @@ describe(Support.getTestDialectTeaser('Paranoid'), () => {
X.hasMany(Y); X.hasMany(Y);
return this.sequelize.sync({ force: true }).then(() => { await this.sequelize.sync({ force: true });
return Promise.all([
X.create(), const [x0, y] = await Promise.all([
Y.create() X.create(),
]); Y.create()
}).then(([x, y]) => { ]);
this.x = x;
this.y = y; this.x = x0;
this.y = y;
return x.addY(y);
}).then(() => { await x0.addY(y);
return this.y.destroy(); await this.y.destroy();
}).then(() => { //prevent CURRENT_TIMESTAMP to be same
//prevent CURRENT_TIMESTAMP to be same this.clock.tick(1000);
this.clock.tick(1000);
const obj = await X.findAll({
return X.findAll({ include: [Y]
include: [Y]
}).then(obj => obj[0]);
}).then(x => {
expect(x.ys).to.have.length(0);
}); });
const x = await obj[0];
expect(x.ys).to.have.length(0);
}); });
}); });
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!