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

Commit 1c43cceb by Mick Hansen

test(include): add additional include test

1 parent cde7ec76
Showing with 46 additions and 0 deletions
...@@ -101,6 +101,52 @@ describe(Support.getTestDialectTeaser("Include"), function () { ...@@ -101,6 +101,52 @@ describe(Support.getTestDialectTeaser("Include"), function () {
}) })
}) })
it('should support a simple sibling set of belongsTo include', function (done) {
var Task = this.sequelize.define('Task', {})
, User = this.sequelize.define('User', {})
, Group = this.sequelize.define('Group', {})
Task.belongsTo(User)
Task.belongsTo(Group)
this.sequelize.sync({force: true}).done(function () {
async.auto({
task: function (callback) {
Task.create().done(callback)
},
user: function (callback) {
User.create().done(callback)
},
group: function (callback) {
Group.create().done(callback)
},
taskUser: ['task', 'user', function (callback, results) {
results.task.setUser(results.user).done(callback)
}],
taskGroup: ['task', 'group', function (callback, results) {
results.task.setGroup(results.group).done(callback)
}]
}, function (err, results) {
expect(err).not.to.be.ok
Task.find({
where: {
id: results.task.id
},
include: [
{model: User},
{model: Group}
]
}).done(function (err, task) {
expect(err).not.to.be.ok
expect(task.user).to.be.ok
expect(task.group).to.be.ok
done()
})
})
})
})
it('should support a simple nested hasOne -> hasOne include', function (done) { it('should support a simple nested hasOne -> hasOne include', function (done) {
var Task = this.sequelize.define('Task', {}) var Task = this.sequelize.define('Task', {})
, User = this.sequelize.define('User', {}) , User = this.sequelize.define('User', {})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!