Skip to content

Commit

Permalink
add test for handle multiple on()/off()
Browse files Browse the repository at this point in the history
  • Loading branch information
kupriyanenko committed Apr 14, 2015
1 parent 9b7b06d commit f42552f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,25 @@ describe('jBone Event', function() {
expect(i).be.eql(2);
});

it('multiple on()/off() handlers per element with namespaces', function() {
var counter = 0,
handler = function() { counter++; },
$el = $('<p></p>');

$el.on('click.space1', handler);
$el.trigger('click');
expect(counter).be.eql(1);

$el.on('click.space2', handler);
$el.trigger('click');
expect(counter).be.eql(3);

$el.off('click.space1');
$el.on('click.space1', handler);
$el.trigger("click");
expect(counter).be.eql(5);
});

it('Event dispather should properly handle removed events', function() {
var a = $('<div>').appendTo('body'),
counter = 0;
Expand Down

0 comments on commit f42552f

Please sign in to comment.