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