Bug Tracker

Changeset 5284

Show
Ignore:
Timestamp:
04/22/08 23:07:35 (7 months ago)
Author:
aflesler
Message:

- adding the tests for the changes to $.makeArray, proposed at #2619

Files:
1 modified

Legend:

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

    r4611 r5284  
    15621562    equals( c[0].nodeValue, "hi", "Check node,textnode,comment contents is just the one from span" ); 
    15631563}); 
     1564 
     1565test("makeArray(#2619)", function(){ 
     1566    expect(11); 
     1567     
     1568    equals( $.makeArray(document.getElementsByName("PWD")).slice(0,1)[0].name, "PWD", "Pass makeArray a nodelist" ); 
     1569 
     1570    equals( (function(){ return $.makeArray(arguments); })(1,2).join(""), "12", "Pass makeArray an arguments array" ); 
     1571 
     1572    equals( $.makeArray([1,2,3]).join(""), "123", "Pass makeArray a real array" ); 
     1573 
     1574    equals( $.makeArray().length, 0, "Pass nothing to makeArray and expect an empty array" ); 
     1575 
     1576    equals( $.makeArray( 0 )[0], 0 , "Pass makeArray a number" ); 
     1577 
     1578    equals( $.makeArray( "foo" )[0], "foo", "Pass makeArray a string" ); 
     1579 
     1580    equals( typeof $.makeArray( true )[0], "boolean", "Pass makeArray a boolean" ); 
     1581 
     1582    equals( $.makeArray( document.createElement("div") )[0].nodeName, "DIV", "Pass makeArray a single node" ); 
     1583 
     1584    equals( $.makeArray( {length:2, 0:"a", 1:"b"} ).join(""), "ab", "Pass makeArray an array like map (with length)" ); 
     1585 
     1586    equals( $.makeArray( document.documentElement.childNodes ).slice(0,1)[0].nodeName, "HEAD", "Pass makeArray a childNodeson array" ); 
     1587 
     1588    //function (tricky, they have length) 
     1589    equals( $.makeArray( function(){ return 1;} )[0](), 1, "Pass makeArray a function" );    
     1590});