Add new tests for Icon cloning. Modify Icon.js to correct incorrect case in constructor call in clone().

git-svn-id: http://svn.openlayers.org/trunk/openlayers@109 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-05-17 17:32:03 +00:00
parent 04ca5d3695
commit 4eec3dae7a
2 changed files with 11 additions and 1 deletions

View File

@@ -14,6 +14,6 @@ OpenLayers.Icon.prototype = {
// Create a copy of this icon.
clone: function() {
return new OpenLayers.icon(this.size, this.url);
return new OpenLayers.Icon(this.size, this.url);
}
}

View File

@@ -13,6 +13,16 @@
t.eq( icon.size.h, 6, "icon.size.w returns correct value" );
t.eq( icon.url, "", "icon.url returns str object" );
}
function test_02_Icon_clone (t) {
t.plan( 4 );
icon = new OpenLayers.Icon("a",new OpenLayers.Size(5,6));
t.ok( icon instanceof OpenLayers.Icon, "new OpenLayers.Icon returns Icon object" );
var cloned = icon.clone();
t.ok( cloned instanceof OpenLayers.Icon, "clone is an OpenLayers.Icon" );
cloned.url = "b"
t.eq( icon.url, "a", "icon.url doesn't change with clone's url" );
t.eq( cloned.url, "b", "cloned.url does change when edited" );
}
// -->
</script>