diff --git a/tests/Tile/WFS.html b/tests/Tile/WFS.html index 3c7fd743e2..3f21ac25bf 100644 --- a/tests/Tile/WFS.html +++ b/tests/Tile/WFS.html @@ -140,41 +140,71 @@ tearDown(); } function test_nonxml_format(t) { - t.plan(1); + t.plan(2); + + setUp(); + var data = '{"type":"Feature", "id":"OpenLayers.Feature.Vector_135", "properties":{}, "geometry":{"type":"Point", "coordinates":[118.125, -18.6328125]}, "crs":{"type":"OGC", "properties":{"urn":"urn:ogc:def:crs:OGC:1.3:CRS84"}}}' var position = new OpenLayers.Pixel(10,20); var bounds = new OpenLayers.Bounds(1,2,3,4); var url = "bobob"; var size = new OpenLayers.Size(5,6); - var tile = new OpenLayers.Tile.WFS({ - vectorMode: true, + var log = []; + + var l = new OpenLayers.Layer(null, { + vectorMode: true, formatObject: new OpenLayers.Format.GeoJSON(), addFeatures: function(features) { - t.eq(features.length, 1, "GeoJSON format returned a single feature which was added.") + log.push(features); } - }, position, bounds, url, size); + }) + map.addLayer(l); + + var tile = new OpenLayers.Tile.WFS(l, position, bounds, url, size); + tile.requestSuccess({responseText: data}); + + t.eq(log.length, 1, "one call logged") + t.eq(log[0] && log[0].length, 1, "GeoJSON format returned a single feature which was added."); + + tearDown(); } function test_xml_string_and_dom(t) { - t.plan(2); + t.plan(4); + setUp(); + var data = ' -94.989723,43.285833 -74.755001,51.709520 -94.142500,50.992777 -94.142500,50.992777 -94.142500,50.992777 ON_2 Suffel Road 50.9927770 -94.1425000 '; var position = new OpenLayers.Pixel(10,20); var bounds = new OpenLayers.Bounds(1,2,3,4); var url = "bobob"; var size = new OpenLayers.Size(5,6); - var tile = new OpenLayers.Tile.WFS({ - }, position, bounds, url, size); + + var l = new OpenLayers.Layer(); + map.addLayer(l); + + var tile = new OpenLayers.Tile.WFS(l, position, bounds, url, size); + + var log = []; tile.addResults = function(results) { - t.eq(results.length, 1, "results count is correct when passing in XML as a string into non-vectormode"); + log.push(results); } tile.requestSuccess({responseText: data}); + t.eq(log.length, 1, "first call logged"); + t.eq(log[0] && log[0].length, 1, "results count is correct when passing in XML as a string into non-vectormode"); + + log.length = 0; tile.addResults = function(results) { - t.eq(results.length, 1, "results count is correct when passing in XML as DOM into non-vectormode"); + log.push(results); } tile.requestSuccess({responseXML: OpenLayers.Format.XML.prototype.read(data)}); + + t.eq(log.length, 1, "second call logged"); + t.eq(log[0] && log[0].length, 1, "results count is correct when passing in XML as DOM into non-vectormode"); + + tearDown(); }