Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): Default remaining client options if any are set #1357

Merged
merged 1 commit into from
May 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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