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

Commit a30588aa by Mick Hansen

test(hasOne): expand hasOne getter with transaction unit test

1 parent bce34621
Showing with 5 additions and 1 deletions
...@@ -29,6 +29,7 @@ describe(Support.getTestDialectTeaser("HasOne"), function() { ...@@ -29,6 +29,7 @@ describe(Support.getTestDialectTeaser("HasOne"), function() {
Group.hasOne(User) Group.hasOne(User)
sequelize.sync({ force: true }).success(function() { sequelize.sync({ force: true }).success(function() {
User.create({ username: 'foo' }).success(function(fakeUser) {
User.create({ username: 'foo' }).success(function(user) { User.create({ username: 'foo' }).success(function(user) {
Group.create({ name: 'bar' }).success(function(group) { Group.create({ name: 'bar' }).success(function(group) {
sequelize.transaction(function(t) { sequelize.transaction(function(t) {
...@@ -38,7 +39,9 @@ describe(Support.getTestDialectTeaser("HasOne"), function() { ...@@ -38,7 +39,9 @@ describe(Support.getTestDialectTeaser("HasOne"), function() {
expect(associatedUser).to.be.null expect(associatedUser).to.be.null
Group.all({ transaction: t }).success(function(groups) { Group.all({ transaction: t }).success(function(groups) {
groups[0].getUser({ transaction: t }).success(function(associatedUser) { groups[0].getUser({ transaction: t }).success(function(associatedUser) {
expect(associatedUser).to.be.not.null expect(associatedUser).not.to.be.null
expect(associatedUser.id).to.equal(user.id)
expect(associatedUser.id).not.to.equal(fakeUser.id)
t.rollback().success(function() { done() }) t.rollback().success(function() { done() })
}) })
}) })
...@@ -51,6 +54,7 @@ describe(Support.getTestDialectTeaser("HasOne"), function() { ...@@ -51,6 +54,7 @@ describe(Support.getTestDialectTeaser("HasOne"), function() {
}) })
}) })
}) })
})
it('should be able to handle a where object that\'s a first class citizen.', function(done) { it('should be able to handle a where object that\'s a first class citizen.', function(done) {
var User = this.sequelize.define('UserXYZ', { username: Sequelize.STRING }) var User = this.sequelize.define('UserXYZ', { username: Sequelize.STRING })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!