Skip to content

Commit

Permalink
added a test for setting output folder and some small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
beatfactor committed Jun 8, 2014
1 parent 41e675d commit da6ee33
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
7 changes: 4 additions & 3 deletions bin/_clirunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ CliRunner.prototype = {
* @returns {CliRunner}
*/
setOutputFolder : function() {
this.output_folder = this.settings.output_folder === false ?
false : (this.cli.command('output').isDefault(this.argv.o)
&& this.settings.output_folder || this.argv.o);
var isDisabled = this.settings.output_folder === false;
var isDefault = this.cli.command('output').isDefault(this.argv.o);

this.output_folder = isDisabled ? false : (isDefault && this.settings.output_folder || this.argv.o);
return this;
},

Expand Down
37 changes: 36 additions & 1 deletion tests/src/runner/testCliRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ module.exports = {
};

mockery.registerMock('./nightwatch.json', config);
mockery.registerMock('./output_disabled.json', {
src_folders : ['tests'],
output_folder : false,
test_settings : {
'default' : {
silent : true
}
}
});

mockery.registerMock('./empty.json', {
src_folders : 'tests'
});
Expand Down Expand Up @@ -91,6 +101,9 @@ module.exports = {
if (b == './custom.json') {
return './custom.json';
}
if (b == './output_disabled.json') {
return './output_disabled.json';
}
if (b == './empty.json') {
return './empty.json';
}
Expand Down Expand Up @@ -152,6 +165,28 @@ module.exports = {

},

testSetOutputFolder : function(test) {
mockery.registerMock('fs', {
existsSync : function(module) {
if (module == './settings.json') {
return false;
}
return true;
}
});

var CliRunner = require('../../../'+ BASE_PATH +'/../bin/_clirunner.js');
var runner = new CliRunner({
c : './output_disabled.json',
e : 'default'
}).init();

test.equals(runner.output_folder, false);

test.done();

},

testReadSettingsDeprecated : function(test) {
mockery.registerMock('../lib/util/logger.js', {
disableColors : function() {
Expand Down Expand Up @@ -388,7 +423,7 @@ module.exports = {
runner.manageSelenium = true;
runner.parallelMode = true;
test.expect(2);

runner.globalErrorHandler = function(err) {
test.equals(err.message, 'Server already running.');
test.equals(runner.settings.parallelMode, true);
Expand Down

0 comments on commit da6ee33

Please sign in to comment.