From 1ac623a54290a12bae80499f8b263172291bba56 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Tue, 15 Mar 2016 18:25:15 -0700 Subject: [PATCH] test both sync and async queries --- package.json | 2 +- test/suite_implementation.js | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 35fdeb1a440..2fd229843f3 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint": "^1.5.0", "eslint-config-mourner": "^1.0.0", "istanbul": "^0.4.1", - "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#5dfc9316d2e60c26ee52da274a2f9c10155912c8", + "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#a47f326d0285b912381f117877636db8c09320ee", "prova": "^2.1.2", "sinon": "^1.15.4", "st": "^1.0.0", diff --git a/test/suite_implementation.js b/test/suite_implementation.js index d32ed1ff044..acf9a55014d 100644 --- a/test/suite_implementation.js +++ b/test/suite_implementation.js @@ -47,26 +47,30 @@ module.exports = function(style, options, callback) { tmp.copy(data, end); } + var syncResults = []; if (options.queryGeometry) { - done(null, map.queryRenderedFeatures(options.queryGeometry, options)); + syncResults = map.queryRenderedFeatures(options.queryGeometry, options); + map.queryRenderedFeaturesAsync(options.queryGeometry, options, done); } else { done(null, []); } - function done(err, results) { + function done(err, asyncResults) { map.remove(); gl.destroy(); if (err) return callback(err); - results = results.map(function (r) { - delete r.layer; - r.geometry = null; - return JSON.parse(JSON.stringify(r)); - }); + syncResults = syncResults.map(prepareFeatures); + asyncResults = asyncResults.map(prepareFeatures); - callback(null, data, results); + callback(null, data, syncResults, asyncResults); } + function prepareFeatures(r) { + delete r.layer; + r.geometry = null; + return JSON.parse(JSON.stringify(r)); + } }); };