From 4eec3dae7af270239b924fa7f387dd5be6f2895d Mon Sep 17 00:00:00 2001 From: crschmidt Date: Wed, 17 May 2006 17:32:03 +0000 Subject: [PATCH] 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 --- lib/OpenLayers/Icon.js | 2 +- tests/test_Icon.html | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Icon.js b/lib/OpenLayers/Icon.js index 880f079dd5..ccf2f6b214 100644 --- a/lib/OpenLayers/Icon.js +++ b/lib/OpenLayers/Icon.js @@ -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); } } diff --git a/tests/test_Icon.html b/tests/test_Icon.html index 41c5a33306..228d5b7e5c 100644 --- a/tests/test_Icon.html +++ b/tests/test_Icon.html @@ -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" ); + } // -->