Skip to content

Commit

Permalink
Fix regression in querySourceFeatures (#3022)
Browse files Browse the repository at this point in the history
  • Loading branch information
anandthakker committed Aug 17, 2016
1 parent 8a8460c commit 036bf53
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js/source/query_features.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ exports.rendered = function(sourceCache, styleLayers, queryGeometry, params, zoo
};

exports.source = function(sourceCache, params) {
var tiles = sourceCache.renderedIDs().map(function(id) {
var tiles = sourceCache.getRenderableIds().map(function(id) {
return sourceCache.getTileByID(id);
});

Expand Down
17 changes: 17 additions & 0 deletions test/js/source/query_features.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

var test = require('tap').test;
var QueryFeatures = require('../../../js/source/query_features.js');
var SourceCache = require('../../../js/source/source_cache.js');

test('QueryFeatures#rendered', function (t) {
t.test('returns empty object if source returns no tiles', function (t) {
Expand All @@ -13,3 +14,19 @@ test('QueryFeatures#rendered', function (t) {

t.end();
});

test('QueryFeatures#source', function (t) {
t.test('returns empty result when source has no features', function (t) {
var sourceCache = new SourceCache('test', {
type: 'geojson',
data: { type: 'FeatureCollection', features: [] }
}, {
send: function (type, params, callback) { return callback(); }
});
var result = QueryFeatures.source(sourceCache, {});
t.deepEqual(result, []);
t.end();
});

t.end();
});

0 comments on commit 036bf53

Please sign in to comment.