diff --git a/query/view/boost_sources_and_layers.js b/query/view/boost_sources_and_layers.js index 7d7626b0..504724da 100644 --- a/query/view/boost_sources_and_layers.js +++ b/query/view/boost_sources_and_layers.js @@ -24,6 +24,9 @@ function generateTermQuery(field, value, boost) { module.exports = function( configuration ) { return function( ) { + if (!configuration) { + return null; + } const filters = []; ['source', 'layer'].forEach(function(target) { if (configuration[target]) { diff --git a/test/unit/query/view/boost_sources_and_layers.js b/test/unit/query/view/boost_sources_and_layers.js index aff6a4d2..f8c7babb 100644 --- a/test/unit/query/view/boost_sources_and_layers.js +++ b/test/unit/query/view/boost_sources_and_layers.js @@ -9,6 +9,13 @@ module.exports.tests.empty_config = function(test, common) { t.equal(query, null, 'query is empty'); t.end(); }); + + test('undefined configuration returns empty query', function(t) { + const view_instance = boost_sources_and_layers(undefined); + const query = view_instance(); + t.equal(query, null, 'query is empty'); + t.end(); + }); }; module.exports.tests.single_item_config = function(test, common) {