aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorDan Heberden <danheberden@gmail.com>2011-03-21 12:12:31 -0700
committerDan Heberden <danheberden@gmail.com>2011-03-21 12:12:31 -0700
commitd832f4f71ec51e67d4cae2557221ef582818f607 (patch)
treefd22a7d34543fc7334e7e288005c9ab224dd401e /test/unit
parente38f074d14fd65b3f8b0e1bd7956cd75b3dafe2b (diff)
downloadjquery-d832f4f71ec51e67d4cae2557221ef582818f607.tar.gz
jquery-d832f4f71ec51e67d4cae2557221ef582818f607.zip
jQuery.map to iterate over objects with a .length property
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/core.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/test/unit/core.js b/test/unit/core.js
index c1ffe10b4..08d80400c 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -608,7 +608,7 @@ test("first()/last()", function() {
});
test("map()", function() {
- expect(6);
+ expect(7);
same(
jQuery("#ap").map(function(){
@@ -630,26 +630,28 @@ test("map()", function() {
var keys = jQuery.map( {a:1,b:2}, function( v, k ){
return k;
});
-
equals( keys.join(""), "ab", "Map the keys from a hash to an array" );
var values = jQuery.map( {a:1,b:2}, function( v, k ){
return v;
});
-
equals( values.join(""), "12", "Map the values from a hash to an array" );
+
+ // object with length prop
+ var values = jQuery.map( {a:1,b:2, length:3}, function( v, k ){
+ return v;
+ });
+ equals( values.join(""), "123", "Map the values from a hash with a length property to an array" );
var scripts = document.getElementsByTagName("script");
var mapped = jQuery.map( scripts, function( v, k ){
return v;
});
-
equals( mapped.length, scripts.length, "Map an array(-like) to a hash" );
var flat = jQuery.map( Array(4), function( v, k ){
return k % 2 ? k : [k,k,k];//try mixing array and regular returns
});
-
equals( flat.join(""), "00012223", "try the new flatten technique(#2616)" );
});