Bug Tracker

Changeset 5353

Show
Ignore:
Timestamp:
04/29/08 22:20:02 (8 months ago)
Author:
aflesler
Message:

test runner: adding a test case for $.fn._toggle with more than 2 functions.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/jquery/test/unit/event.js

    r5280 r5353  
    272272}); 
    273273 
    274 test("toggle(Function, Function)", function() { 
    275     expect(5); 
     274test("toggle(Function, Function, ...)", function() { 
     275    expect(11); 
     276     
    276277    var count = 0, 
    277278        fn1 = function(e) { count++; }, 
     
    296297        return false; 
    297298    }).click().click().click(); 
     299     
     300    var turn = 0; 
     301    var fns = [ 
     302        function(){ 
     303            turn = 1; 
     304        }, 
     305        function(){ 
     306            turn = 2; 
     307        }, 
     308        function(){ 
     309            turn = 3; 
     310        } 
     311    ]; 
     312     
     313    var $div = $("<div>&nbsp;</div>").toggle( fns[0], fns[1], fns[2] ); 
     314    $div.click(); 
     315    ok( turn == 1, "Trying toggle with 3 functions, attempt 1 yields 1"); 
     316    $div.click(); 
     317    ok( turn == 2, "Trying toggle with 3 functions, attempt 2 yields 2"); 
     318    $div.click(); 
     319    ok( turn == 3, "Trying toggle with 3 functions, attempt 3 yields 3"); 
     320    $div.click(); 
     321    ok( turn == 1, "Trying toggle with 3 functions, attempt 4 yields 1"); 
     322    $div.click(); 
     323    ok( turn == 2, "Trying toggle with 3 functions, attempt 5 yields 2"); 
     324     
     325    $div.unbind('click',fns[0]); 
     326    var data = $.data( $div[0], 'events' ); 
     327    ok( !data, "Unbinding one function from toggle unbinds them all"); 
    298328}); 
    299329