From be246326ee1eab133bca0af855a4b9aa097bb8d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Sun, 27 Dec 2009 22:05:10 +0000 Subject: [PATCH] test that "featuresremoved" listeners are passed the expected features when all the features of the layer are being removed, no functional change git-svn-id: http://svn.openlayers.org/trunk/openlayers@9928 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- tests/Layer/Vector.html | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/Layer/Vector.html b/tests/Layer/Vector.html index a8e6636744..03e5378745 100644 --- a/tests/Layer/Vector.html +++ b/tests/Layer/Vector.html @@ -130,10 +130,10 @@ } function test_Layer_Vector_removeFeatures(t) { - t.plan(9); + t.plan(13); var layer = new OpenLayers.Layer.Vector(name); - var features; + var features, log; var point1 = new OpenLayers.Geometry.Point(-111.04, 45.68); var pointFeature1 = new OpenLayers.Feature.Vector(layer, point1); @@ -156,6 +156,23 @@ t.ok(layer.features.length == 0, "OpenLayers.Layer.Vector.removeFeatures(layer.features) removes all feature from the features array"); + // 4 tests + log = []; + layer.addFeatures([pointFeature1, pointFeature2]); + layer.events.register("featuresremoved", null, function(obj) { + log.push(obj); + }); + layer.removeFeatures(layer.features); + t.eq(log.length, 1, + "\"featuresremoved\" triggered once"); + t.eq(log[0].features.length, 2, + "\"featuresremoved\" listener is passed two features"); + t.ok(log[0].features[0] == pointFeature1, + "\"featuresremoved\" listener is passed the correct feature at index 0"); + t.ok(log[0].features[1] == pointFeature2, + "\"featuresremoved\" listener is passed the correct feature at index 1"); + layer.events.remove("featuresremoved"); + // 6 tests layer.events.register('beforefeatureremoved', null, function(obj) { t.ok(pointFeature1 == obj.feature,