Skip to content

Commit

Permalink
Tests for response property on loadend event.
Browse files Browse the repository at this point in the history
This confirms that the loadend event includes a response property when it results from a call to the strategy merge method (see openlayers#624).
  • Loading branch information
tschaub committed Aug 8, 2012
1 parent 7e326f9 commit 970448e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions tests/Strategy/BBOX.html
Expand Up @@ -112,16 +112,18 @@

function test_events(t) {

t.plan(5);
t.plan(6);

var log = [];

var response = new OpenLayers.Protocol.Response();

var map = new OpenLayers.Map("map");
var layer = new OpenLayers.Layer.Vector(null, {
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: new OpenLayers.Protocol({
read: function(config) {
config.callback.call(config.scope, {});
config.callback.call(config.scope, response);
}
}),
isBaseLayer: true,
Expand All @@ -140,6 +142,7 @@
t.eq(log.length, 2, "2 events logged");
t.eq(log[0].type, "loadstart", "loadstart first");
t.eq(log[1].type, "loadend", "loadend second");
t.ok(log[1].response == response, "loadend includes response");

var calls = [];
layer.protocol.read = function(obj) {
Expand Down
9 changes: 6 additions & 3 deletions tests/Strategy/Fixed.html
Expand Up @@ -62,16 +62,18 @@

function test_events(t) {

t.plan(5);
t.plan(6);

var log = [];

var response = new OpenLayers.Protocol.Response();

var map = new OpenLayers.Map("map");
var layer = new OpenLayers.Layer.Vector(null, {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol({
read: function(config) {
config.callback.call(config.scope, {});
config.callback.call(config.scope, response);
}
}),
isBaseLayer: true,
Expand All @@ -87,10 +89,11 @@

map.addLayer(layer);
map.zoomToMaxExtent();

t.eq(log.length, 2, "2 events logged");
t.eq(log[0].type, "loadstart", "loadstart first");
t.eq(log[1].type, "loadend", "loadend second");
t.ok(log[1].response == response, "loadend includes response");

var calls = [];
layer.protocol.read = function(obj) {
Expand Down

0 comments on commit 970448e

Please sign in to comment.