Commit ab756cea authored by Jörn Zaefferer's avatar Jörn Zaefferer

jquery core: tests for #2616

parent b84b997e
...@@ -1511,7 +1511,7 @@ test("slice()", function() { ...@@ -1511,7 +1511,7 @@ test("slice()", function() {
}); });
test("map()", function() { test("map()", function() {
expect(2); expect(6);
isSet( isSet(
$("#ap").map(function(){ $("#ap").map(function(){
...@@ -1528,6 +1528,32 @@ test("map()", function() { ...@@ -1528,6 +1528,32 @@ test("map()", function() {
q("ap","ap","ap"), q("ap","ap","ap"),
"Single Map" "Single Map"
); );
//for #2616
var keys = $.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 = $.map( {a:1,b:2}, function( v, k ){
return v;
}, [ ] );
equals( values.join(""), "12", "Map the values from a hash to an array" );
var scripts = document.getElementsByTagName("script");
var mapped = $.map( scripts, function( v, k ){
return v;
}, {length:0} );
equals( mapped.length, scripts.length, "Map an array(-like) to a hash" );
var flat = $.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)" );
}); });
test("contents()", function() { test("contents()", function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment