diff --git a/app/js/arethusa.core/configurator.service.js b/app/js/arethusa.core/configurator.service.js index c44b4b77e..cdd316886 100644 --- a/app/js/arethusa.core/configurator.service.js +++ b/app/js/arethusa.core/configurator.service.js @@ -8,10 +8,14 @@ angular.module('arethusa.core').service('configurator', function($injector) { }; this.getServices = function(serviceNames) { - var that = this; - return arethusaUtil.map(serviceNames, function(name) { - return that.getService(name); - }); + if (serviceNames) { + var that = this; + return arethusaUtil.map(serviceNames, function(name) { + return that.getService(name); + }); + } else { + return []; + } }; // this.configuration is set from outside on page load diff --git a/spec/arethusa.core/configurator.service_spec.js b/spec/arethusa.core/configurator.service_spec.js index cb1ae4b91..425ffa00d 100644 --- a/spec/arethusa.core/configurator.service_spec.js +++ b/spec/arethusa.core/configurator.service_spec.js @@ -30,5 +30,11 @@ describe('configurator', function() { expect(services).toContain(mock1); expect(services).toContain(mock2); })); + + it('returns an empty array when no service names are given', inject(function(configurator) { + var names = undefined; + var services = configurator.getServices(names); + expect(services).toEqual([]); + })); }); });