Browse Source

Test handling of undefined configuration

configurable-boosts
Julian Simioni 7 years ago
parent
commit
9679c14152
No known key found for this signature in database
GPG Key ID: B9EEB0C6EE0910A1
  1. 3
      query/view/boost_sources_and_layers.js
  2. 7
      test/unit/query/view/boost_sources_and_layers.js

3
query/view/boost_sources_and_layers.js

@ -24,6 +24,9 @@ function generateTermQuery(field, value, boost) {
module.exports = function( configuration ) { module.exports = function( configuration ) {
return function( ) { return function( ) {
if (!configuration) {
return null;
}
const filters = []; const filters = [];
['source', 'layer'].forEach(function(target) { ['source', 'layer'].forEach(function(target) {
if (configuration[target]) { if (configuration[target]) {

7
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.equal(query, null, 'query is empty');
t.end(); 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) { module.exports.tests.single_item_config = function(test, common) {

Loading…
Cancel
Save