X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=test%2Funit%2Fevent.js;h=2b4d8e59c693bc091f9c3ce1286644eeca8f3938;hb=ac00fe5bbb2a95fdb747f76fd9dd7c58ba6a531c;hp=197406b66bd35646ccb43e807b660fb0460fe119;hpb=9ebb2fc654d51244618e208705e2258fe733058f;p=jquery.git diff --git a/test/unit/event.js b/test/unit/event.js index 197406b..2b4d8e5 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -532,7 +532,7 @@ test("jQuery.Event.currentTarget", function(){ }); test("toggle(Function, Function, ...)", function() { - expect(11); + expect(16); var count = 0, fn1 = function(e) { count++; }, @@ -585,6 +585,22 @@ test("toggle(Function, Function, ...)", function() { $div.unbind('click',fns[0]); var data = jQuery.data( $div[0], 'events' ); ok( !data, "Unbinding one function from toggle unbinds them all"); + + // Test Multi-Toggles + var a = [], b = []; + $div = jQuery("
"); + $div.toggle(function(){ a.push(1); }, function(){ a.push(2); }); + $div.click(); + same( a, [1], "Check that a click worked." ); + + $div.toggle(function(){ b.push(1); }, function(){ b.push(2); }); + $div.click(); + same( a, [1,2], "Check that a click worked with a second toggle." ); + same( b, [1], "Check that a click worked with a second toggle." ); + + $div.click(); + same( a, [1,2,1], "Check that a click worked with a second toggle, second click." ); + same( b, [1,2], "Check that a click worked with a second toggle, second click." ); }); test(".live()/.die()", function() { @@ -798,6 +814,22 @@ test(".live()/.die()", function() { jQuery('span#liveSpan1').die('click'); }); +test("live with submit", function() { + var count = 0; + + jQuery("#testForm").live("submit", function() { + count++; + return false; + }); + + jQuery("#testForm input[name=sub1]")[0].click(); + jQuery("#testForm input[name=T1]").trigger({type: "keypress", keyCode: 13}); + + equals(2, count); + + jQuery("#testForm").die("submit"); +}); + test("live with focus/blur", function(){ expect(2);