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
This commit is contained in:
Éric Lemoine
2009-12-27 22:05:10 +00:00
parent 52e055294f
commit be246326ee

View File

@@ -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,