Fix a typo in Layer.Vector.destroy and add unit tests for protocol and strategies construct/destroy, r=crschmidt (closes #1659)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@7703 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -228,7 +228,7 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
* Destroy this layer
|
||||
*/
|
||||
destroy: function() {
|
||||
if (this.stategies) {
|
||||
if (this.strategies) {
|
||||
for(var i=0, len=this.strategies.length; i<len; i++) {
|
||||
this.strategies[i].destroy();
|
||||
}
|
||||
|
||||
@@ -6,13 +6,19 @@
|
||||
var name = "Vector Layer";
|
||||
|
||||
function test_Layer_Vector_constructor(t) {
|
||||
t.plan(3);
|
||||
t.plan(4);
|
||||
|
||||
var options = {protocol: new OpenLayers.Protocol(),
|
||||
strategies: [new OpenLayers.Strategy(), new OpenLayers.Strategy()]}
|
||||
var layer = new OpenLayers.Layer.Vector(name, options);
|
||||
|
||||
var layer = new OpenLayers.Layer.Vector(name);
|
||||
t.ok(layer instanceof OpenLayers.Layer.Vector, "new OpenLayers.Layer.Vector returns correct object" );
|
||||
t.eq(layer.name, name, "layer name is correctly set");
|
||||
t.ok(layer.renderer.CLASS_NAME, "layer has a renderer");
|
||||
|
||||
t.ok((layer.name == layer.strategies[0].layer.name) &&
|
||||
(layer.strategies[0].layer.name == layer.strategies[1].layer.name),
|
||||
"setLayer was called on strategies");
|
||||
}
|
||||
|
||||
function test_Layer_Vector_addFeatures(t) {
|
||||
@@ -216,13 +222,20 @@
|
||||
}
|
||||
|
||||
function test_Layer_Vector_destroy (t) {
|
||||
t.plan(2);
|
||||
layer = new OpenLayers.Layer.Vector(name);
|
||||
t.plan(4);
|
||||
|
||||
var options = {protocol: new OpenLayers.Protocol(),
|
||||
strategies: [new OpenLayers.Strategy(), new OpenLayers.Strategy()]}
|
||||
var layer = new OpenLayers.Layer.Vector(name, options);
|
||||
var map = new OpenLayers.Map('map');
|
||||
map.addLayer(layer);
|
||||
layer.destroy();
|
||||
t.eq(layer.map, null, "layer.map is null after destroy");
|
||||
t.eq(layer.getFeatureFromEvent({'target':'map'}), null, "getFeatureIdFromEvent doesn't cause an error when called on layer which has been destroyed.");
|
||||
t.eq(layer.getFeatureFromEvent({'target':'map'}), null,
|
||||
"getFeatureIdFromEvent doesn't cause an error when called on layer which has been destroyed.");
|
||||
|
||||
t.eq(layer.protocol, null, "layer.protocol is null after destroy");
|
||||
t.eq(layer.strategies, null, "layer.strategies is null after destroy");
|
||||
}
|
||||
|
||||
function test_Layer_Vector_externalGraphic(t) {
|
||||
|
||||
Reference in New Issue
Block a user