From 632dd5e329191bff0bc85d9bcf58657143315adc Mon Sep 17 00:00:00 2001 From: Awad Mackie Date: Thu, 19 Mar 2015 00:34:04 +0000 Subject: [PATCH] fix(config): Default remaining client options if any are set Closes #961 --- lib/config.js | 8 +++++++- test/unit/config.spec.coffee | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/config.js b/lib/config.js index c353c1938..02cd8ec36 100644 --- a/lib/config.js +++ b/lib/config.js @@ -138,6 +138,12 @@ var normalizeConfig = function(config, configFilePath) { throw new Error('Invalid configuration: client.args must be an array of strings'); } + var defaultClient = config.defaultClient || {}; + Object.keys(defaultClient).forEach(function(key) { + var option = config.client[key]; + config.client[key] = helper.isDefined(option) ? option : defaultClient[key]; + }); + // normalize preprocessors var preprocessors = config.preprocessors || {}; var normalizedPreprocessors = config.preprocessors = Object.create(null); @@ -225,7 +231,7 @@ var Config = function() { this.loggers = [constant.CONSOLE_APPENDER]; this.transports = ['websocket', 'flashsocket', 'xhr-polling', 'jsonp-polling']; this.plugins = ['karma-*']; - this.client = { + this.defaultClient = this.client = { args: [], useIframe: true, captureConsole: true diff --git a/test/unit/config.spec.coffee b/test/unit/config.spec.coffee index ca67a2e04..182561293 100644 --- a/test/unit/config.spec.coffee +++ b/test/unit/config.spec.coffee @@ -207,6 +207,22 @@ describe 'config', -> expect(config.basePath).to.equal resolveWinPath('./some') expect(config.urlRoot).to.equal '/' # default value + it 'should default unset options in client config', -> + config = e.parseConfig null, {client: {args: ['--test']}} + + expect(config.client.useIframe).to.not.be.undefined + expect(config.client.captureConsole).to.not.be.undefined + + config = e.parseConfig null, {client: {useIframe: true}} + + expect(config.client.args).to.not.be.undefined + expect(config.client.captureConsole).to.not.be.undefined + + config = e.parseConfig null, {client: {captureConsole: true}} + + expect(config.client.useIframe).to.not.be.undefined + expect(config.client.args).to.not.be.undefined + describe 'normalizeConfig', ->