Skip to content

Commit

Permalink
Add tests for any/all in filters
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Oct 10, 2017
1 parent 81babb0 commit 452b92f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/style-spec/feature_filter/index.js
Expand Up @@ -33,7 +33,7 @@ function isExpressionFilter(filter) {
case 'any':
case 'all':
for (const f of filter.slice(1)) {
if (!isExpressionFilter(f)) {
if (!isExpressionFilter(f) && typeof f !== 'boolean') {
return false;
}
}
Expand Down
12 changes: 12 additions & 0 deletions test/unit/style-spec/feature_filter.test.js
Expand Up @@ -25,6 +25,18 @@ test('expression, compare two properties', (t) => {
t.end();
});

test('expression, any/all', (t) => {
t.equal(filter(['all'])(), true);
t.equal(filter(['all', true])(), true);
t.equal(filter(['all', true, false])(), false);
t.equal(filter(['all', true, true])(), true);
t.equal(filter(['any'])(), false);
t.equal(filter(['any', true])(), true);
t.equal(filter(['any', true, false])(), true);
t.equal(filter(['any', false, false])(), false);
t.end();
});

test('expression, type error', (t) => {
t.throws(() => {
filter(['==', ['number', ['get', 'x']], ['string', ['get', 'y']]]);
Expand Down

0 comments on commit 452b92f

Please sign in to comment.