X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fevent.js;h=b0cc5026dc246b1ccb6c8636ed077ae1f4f0ff4a;hb=cb65daa399630de0cdcd81af55ff76f6cd93da62;hp=30ed09e295e67293e2b13cb2bd94fb765499d82a;hpb=0474917c9d82fa13d865282d2da2d3cb6e5b89ec;p=jquery.git diff --git a/test/unit/event.js b/test/unit/event.js index 30ed09e..b0cc502 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -71,6 +71,52 @@ test("bind(), multiple events at once and namespaces", function() { div.trigger("focusout.b"); }); +test("bind(), namespace with special add", function() { + expect(18); + + var div = jQuery("
").bind("test", function(e) { + ok( true, "Test event fired." ); + }); + + var i = 0; + + jQuery.event.special.test = { + _default: function(e) { + equals( this, document, "Make sure we're at the top of the chain." ); + equals( e.type, "test", "And that we're still dealing with a test event." ); + equals( e.target, div[0], "And that the target is correct." ); + }, + setup: function(){}, + teardown: function(){}, + add: function( handler, data, namespaces ) { + return function(e) { + e.xyz = ++i; + handler.apply( this, arguments ); + }; + }, + remove: function() {} + }; + + div.bind("test.a", {x: 1}, function(e) { + ok( !!e.xyz, "Make sure that the data is getting passed through." ); + equals( e.data.x, 1, "Make sure data is attached properly." ); + }); + + div.bind("test.b", {x: 2}, function(e) { + ok( !!e.xyz, "Make sure that the data is getting passed through." ); + equals( e.data.x, 2, "Make sure data is attached properly." ); + }); + + // Should trigger 5 + div.trigger("test"); + + // Should trigger 2 + div.trigger("test.a"); + + // Should trigger 2 + div.trigger("test.b"); +}); + test("bind(), no data", function() { expect(1); var handler = function(event) {