Skip to content

Commit

Permalink
test both sync and async queries
Browse files Browse the repository at this point in the history
  • Loading branch information
ansis committed Mar 16, 2016
1 parent 2fd662e commit 1ac623a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 12 additions & 8 deletions test/suite_implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
});
};

0 comments on commit 1ac623a

Please sign in to comment.