Skip to content

Commit

Permalink
fix(config): Default remaining client options if any are set
Browse files Browse the repository at this point in the history
Closes #961
  • Loading branch information
firesock committed Apr 22, 2015
1 parent 482654c commit 632dd5e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions test/unit/config.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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', ->

Expand Down

0 comments on commit 632dd5e

Please sign in to comment.