jquery core: tests for #2616

This commit is contained in:
Jörn Zaefferer 2008-04-28 14:00:27 +00:00
parent b84b997ea4
commit ab756ceab0

View file

@ -1511,7 +1511,7 @@ test("slice()", function() {
});
test("map()", function() {
expect(2);
expect(6);
isSet(
$("#ap").map(function(){
@ -1528,6 +1528,32 @@ test("map()", function() {
q("ap","ap","ap"),
"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() {