Skip to content

Commit

Permalink
test delegate returns listener
Browse files Browse the repository at this point in the history
  • Loading branch information
akre54 committed Mar 14, 2014
1 parent 06586f3 commit f67c7a1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,21 @@
equal(counter2, 3);
});

test("delegate", 2, function() {
test("delegate", 4, function() {
var counter1 = 0, counter2 = 0;

var view = new Backbone.View({el: '#testElement'});
view.increment = function(){ counter1++; };
view.$el.on('click', function(){ counter2++; });

view.delegate('click', 'h1', view.increment);
view.delegate('click', view.increment);
var listener1 = view.delegate('click', 'h1', view.increment);
var listener2 = view.delegate('click', view.increment);

view.$('h1').trigger('click');
equal(counter1, 2);
equal(counter2, 1);
strictEqual(listener1, view.increment);
strictEqual(listener2, view.increment);
});

test("delegateEvents allows functions for callbacks", 3, function() {
Expand Down

0 comments on commit f67c7a1

Please sign in to comment.