Skip to content
Browse files

added tests for jquery support

  • Loading branch information...
1 parent 08eea29 commit e3912f8c898678f57b95c91fcc81633b31bb5f48 @jsoverson jsoverson committed Oct 5, 2012
Showing with 30 additions and 0 deletions.
  1. +30 −0 spec/javascripts/eventbinder.jquery.spec.js
View
30 spec/javascripts/eventbinder.jquery.spec.js
@@ -0,0 +1,30 @@
+describe("When binding to a jQuery object", function(){
+
+ var binding, binder, element, handler;
+
+ beforeEach(function(){
+ handler = jasmine.createSpy().andCallFake(function(){
+ console.log('clicked')
+ });
+ binder = new Backbone.EventBinder();
+ element = $('<p></p>');
+ binding = binder.bindTo(element, "click", handler);
+ });
+
+ it("should store binding with type 'jquery'", function(){
+ expect(binding.type).toEqual('jquery');
+ });
+
+ it("should execute the handler upon simulated click", function(){
+ element.click();
+ expect(handler).toHaveBeenCalled();
+ });
+
+ it("should unbind handlers", function(){
+ binder.unbindAll();
+ element.click();
+ expect(handler).not.toHaveBeenCalled();
+ });
+
+});
+

0 comments on commit e3912f8

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