Skip to content
Browse files

fix view binding

  • Loading branch information...
1 parent d96a048 commit a27c08a60f25dbe5fda55c24e40e8b564ff2e109 @petrjanda committed
Showing with 17 additions and 6 deletions.
  1. +1 −1 lib/view.js
  2. +16 −5 spec/viewSpec.js
View
2 lib/view.js
@@ -109,7 +109,7 @@ View.prototype.load = function(callback) {
self.lastEvent = data.lastEvent
}
- if(callback) callback(data);
+ if(callback) callback.call(self);
})
}
View
21 spec/viewSpec.js
@@ -209,15 +209,26 @@ describe('View', function() {
expect(view.lastEvent).toEqual(1325721336913);
})
+ describe('callback', function() {
+ it( 'should be called if specified', function() {
+ this.handler = function() {}
+ spyOn( this, 'handler')
- it( 'should call callback if specified', function() {
- this.handler = function() {}
- spyOn( this, 'handler')
+ view.load(this.handler);
- view.load(this.handler);
+ expect( this.handler ).toHaveBeenCalledWith();
+ })
- expect( this.handler ).toHaveBeenCalled();
+ it( 'should be called with proper binding', function() {
+ var self = null;
+ this.handler = function() { self = this; }
+
+ view.load(this.handler);
+
+ expect(self).toEqual(view);
+ })
})
+
})
})

0 comments on commit a27c08a

Please sign in to comment.
Something went wrong with that request. Please try again.