diff options
author | Ariel Flesler <aflesler@gmail.com> | 2008-04-22 23:07:35 +0000 |
---|---|---|
committer | Ariel Flesler <aflesler@gmail.com> | 2008-04-22 23:07:35 +0000 |
commit | 291f071eff51bc0653aaf3dcfd777cc57437ebdf (patch) | |
tree | 5b2b6da4459c7910c3fd8b12bdb49f64c5754a64 /test/unit | |
parent | f861c88b1bb8f9c0bf37ec86cb12a3f7206680c3 (diff) | |
download | jquery-291f071eff51bc0653aaf3dcfd777cc57437ebdf.tar.gz jquery-291f071eff51bc0653aaf3dcfd777cc57437ebdf.zip |
- adding the tests for the changes to $.makeArray, proposed at #2619
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/core.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/unit/core.js b/test/unit/core.js index 3cb90aa78..412ba39c3 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -1561,3 +1561,30 @@ test("contents()", function() { equals( c.length, 1, "Check node,textnode,comment contents is just one" ); equals( c[0].nodeValue, "hi", "Check node,textnode,comment contents is just the one from span" ); }); + +test("makeArray(#2619)", function(){ + expect(11); + + equals( $.makeArray(document.getElementsByName("PWD")).slice(0,1)[0].name, "PWD", "Pass makeArray a nodelist" ); + + equals( (function(){ return $.makeArray(arguments); })(1,2).join(""), "12", "Pass makeArray an arguments array" ); + + equals( $.makeArray([1,2,3]).join(""), "123", "Pass makeArray a real array" ); + + equals( $.makeArray().length, 0, "Pass nothing to makeArray and expect an empty array" ); + + equals( $.makeArray( 0 )[0], 0 , "Pass makeArray a number" ); + + equals( $.makeArray( "foo" )[0], "foo", "Pass makeArray a string" ); + + equals( typeof $.makeArray( true )[0], "boolean", "Pass makeArray a boolean" ); + + equals( $.makeArray( document.createElement("div") )[0].nodeName, "DIV", "Pass makeArray a single node" ); + + equals( $.makeArray( {length:2, 0:"a", 1:"b"} ).join(""), "ab", "Pass makeArray an array like map (with length)" ); + + equals( $.makeArray( document.documentElement.childNodes ).slice(0,1)[0].nodeName, "HEAD", "Pass makeArray a childNodeson array" ); + + //function (tricky, they have length) + equals( $.makeArray( function(){ return 1;} )[0](), 1, "Pass makeArray a function" ); +});
\ No newline at end of file |