Bug Tracker

Changeset 5342

Show
Ignore:
Timestamp:
04/28/08 14:00:27 (7 months ago)
Author:
joern.zaefferer
Message:

jquery core: tests for #2616

Files:
1 modified

Legend:

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

    r5318 r5342  
    15121512 
    15131513test("map()", function() { 
    1514     expect(2); 
     1514    expect(6); 
    15151515 
    15161516    isSet( 
     
    15291529        "Single Map" 
    15301530    ); 
     1531     
     1532    //for #2616 
     1533    var keys = $.map( {a:1,b:2}, function( v, k ){ 
     1534        return k; 
     1535    }, [ ] ); 
     1536 
     1537    equals( keys.join(""), "ab", "Map the keys from a hash to an array" ); 
     1538     
     1539    var values = $.map( {a:1,b:2}, function( v, k ){ 
     1540        return v; 
     1541    }, [ ] ); 
     1542 
     1543    equals( values.join(""), "12", "Map the values from a hash to an array" ); 
     1544     
     1545    var scripts = document.getElementsByTagName("script"); 
     1546    var mapped = $.map( scripts, function( v, k ){ 
     1547        return v; 
     1548    }, {length:0} ); 
     1549 
     1550    equals( mapped.length, scripts.length, "Map an array(-like) to a hash" ); 
     1551     
     1552    var flat = $.map( Array(4), function( v, k ){ 
     1553        return k % 2 ? k : [k,k,k];//try mixing array and regular returns 
     1554    }); 
     1555     
     1556    equals( flat.join(""), "00012223", "try the new flatten technique(#2616)" ); 
    15311557}); 
    15321558