(options, test)
| 13 | const teamAlias = class="st">'Toto'; |
| 14 | |
| 15 | const executeTest = async (options, test) => { |
| 16 | const sequelize = Support.createSequelizeInstance(options); |
| 17 | |
| 18 | const User = sequelize.define(class="st">'User', { name: DataTypes.STRING, updatedAt: DataTypes.DATE }, { underscored: true }); |
| 19 | const Team = sequelize.define(class="st">'Team', { name: DataTypes.STRING }); |
| 20 | const Task = sequelize.define(class="st">'Task', { title: DataTypes.STRING }); |
| 21 | |
| 22 | User.belongsTo(Task, { as: taskAlias, foreignKey: class="st">'task_id' }); |
| 23 | User.belongsToMany(Team, { as: teamAlias, foreignKey: class="st">'teamId', through: class="st">'UserTeam' }); |
| 24 | Team.belongsToMany(User, { foreignKey: class="st">'userId', through: class="st">'UserTeam' }); |
| 25 | |
| 26 | await sequelize.sync({ force: true }); |
| 27 | const team = await Team.create({ name: class="st">'rocket' }); |
| 28 | const task = await Task.create({ title: class="st">'SuperTask' }); |
| 29 | const user = await User.create({ name: class="st">'test', task_id: task.id, updatedAt: new Date() }); |
| 30 | await user[`add${teamAlias}`](team); |
| 31 | |
| 32 | return test(await User.findOne({ |
| 33 | include: [ |
| 34 | { |
| 35 | model: Task, |
| 36 | as: taskAlias |
| 37 | }, |
| 38 | { |
| 39 | model: Team, |
| 40 | as: teamAlias |
| 41 | } |
| 42 | ] |
| 43 | })); |
| 44 | }; |
| 45 | |
| 46 | it(class="st">'should throw due to alias being truncated', async function() { |
| 47 | const options = { ...this.sequelize.options, minifyAliases: false }; |
no test coverage detected