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

Commit f977d945 by Mick Hansen

[test] provide tests for empty 1:1 include cases

1 parent 79a93b9f
Showing with 36 additions and 0 deletions
...@@ -22,6 +22,42 @@ var sortById = function(a, b) { ...@@ -22,6 +22,42 @@ var sortById = function(a, b) {
describe(Support.getTestDialectTeaser("Include"), function () { describe(Support.getTestDialectTeaser("Include"), function () {
describe('find', function () { describe('find', function () {
it('should support a empty belongsTo include', function (done) {
var Company = this.sequelize.define('Company', {})
, User = this.sequelize.define('User', {})
User.belongsTo(Company, {as: 'Employer'})
this.sequelize.sync({force: true}).done(function () {
User.create().then(function () {
User.find({
include: [{model: Company, as: 'Employer'}]
}).done(function (err, user) {
expect(err).not.to.be.ok
expect(user).to.be.ok
done()
})
}, done)
})
})
it('should support a empty hasOne include', function (done) {
var Company = this.sequelize.define('Company', {})
, Person = this.sequelize.define('Person', {})
Company.hasOne(Person, {as: 'CEO'})
this.sequelize.sync({force: true}).done(function () {
Company.create().then(function () {
Company.find({
include: [{model: Person, as: 'CEO'}]
}).done(function (err, company) {
expect(err).not.to.be.ok
expect(company).to.be.ok
done()
})
}, done)
})
})
it('should support a simple nested belongsTo -> belongsTo include', function (done) { it('should support a simple nested belongsTo -> belongsTo 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!