Skip to content

Commit

Permalink
Fix tests from revision 140fbdd
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyba committed Feb 28, 2015
1 parent 140fbdd commit 9805a70
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 31 deletions.
16 changes: 11 additions & 5 deletions javascript/node/selenium-webdriver/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,11 @@ Options.fromCapabilities = function(capabilities) {
* @return {!Options} A self reference.
*/
Options.prototype.addArguments = function(var_args) {
this.options_.args = (this.options_.args || [])
.concat.apply(this.args_, arguments);
var args = this.options_.args || [];
args = args.concat.apply(args, arguments);
if (args.length) {
this.options_.args = args;
}
return this;
};

Expand All @@ -425,8 +428,11 @@ Options.prototype.addArguments = function(var_args) {
* @return {!Options} A self reference.
*/
Options.prototype.excludeSwitches = function(var_args) {
this.options_.excludeSwitches = (this.options_.excludeSwitches || [])
.concat.apply(this.args_, arguments);
var switches = this.options_.excludeSwitches || [];
switches = switches.concat.apply(switches, arguments);
if (switches.length) {
this.options_.excludeSwitches = switches;
}
return this;
};

Expand Down Expand Up @@ -571,7 +577,7 @@ Options.prototype.androidDeviceSerial = function(serial) {

/**
* Configures the ChromeDriver to launch Chrome on Android via adb. This
* function is shorthand for
* function is shorthand for
* {@link #androidPackage options.androidPackage('com.android.chrome')}.
* @return {!Options} A self reference.
*/
Expand Down
54 changes: 28 additions & 26 deletions javascript/node/selenium-webdriver/test/chrome/options_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ describe('chrome.Options', function() {
});

it('should rebuild options from wire representation', function() {
var expectedExtension = fs.readFileSync(__filename, 'base64');
var caps = webdriver.Capabilities.chrome().set('chromeOptions', {
args: ['a', 'b'],
extensions: [1, 2],
extensions: [__filename],
binary: 'binaryPath',
logPath: 'logFilePath',
detach: true,
Expand All @@ -55,18 +56,18 @@ describe('chrome.Options', function() {
});

var options = chrome.Options.fromCapabilities(caps);

assert(options.args_.length).equalTo(2);
assert(options.args_[0]).equalTo('a');
assert(options.args_[1]).equalTo('b');
assert(options.extensions_.length).equalTo(2);
assert(options.extensions_[0]).equalTo(1);
assert(options.extensions_[1]).equalTo(2);
assert(options.binary_).equalTo('binaryPath');
assert(options.logFile_).equalTo('logFilePath');
assert(options.detach_).equalTo(true);
assert(options.localState_).equalTo('localStateValue');
assert(options.prefs_).equalTo('prefsValue');
var json = options.serialize();

assert(json.args.length).equalTo(2);
assert(json.args[0]).equalTo('a');
assert(json.args[1]).equalTo('b');
assert(json.extensions.length).equalTo(1);
assert(json.extensions[0]).equalTo(expectedExtension);
assert(json.binary).equalTo('binaryPath');
assert(json.logPath).equalTo('logFilePath');
assert(json.detach).equalTo(true);
assert(json.localState).equalTo('localStateValue');
assert(json.prefs).equalTo('prefsValue');
});

it('should rebuild options from incomplete wire representation',
Expand All @@ -77,7 +78,6 @@ describe('chrome.Options', function() {

var options = chrome.Options.fromCapabilities(caps);
var json = options.serialize();

assert(json.args).isUndefined();
assert(json.binary).isUndefined();
assert(json.detach).isUndefined();
Expand Down Expand Up @@ -107,26 +107,28 @@ describe('chrome.Options', function() {
describe('addArguments', function() {
it('takes var_args', function() {
var options = new chrome.Options();
assert(options.args_.length).equalTo(0);
assert(options.serialize().args).isUndefined();

options.addArguments('a', 'b');
assert(options.args_.length).equalTo(2);
assert(options.args_[0]).equalTo('a');
assert(options.args_[1]).equalTo('b');
var json = options.serialize();
assert(json.args.length).equalTo(2);
assert(json.args[0]).equalTo('a');
assert(json.args[1]).equalTo('b');
});

it('flattens input arrays', function() {
var options = new chrome.Options();
assert(options.args_.length).equalTo(0);
assert(options.serialize().args).isUndefined();

options.addArguments(['a', 'b'], 'c', [1, 2], 3);
assert(options.args_.length).equalTo(6);
assert(options.args_[0]).equalTo('a');
assert(options.args_[1]).equalTo('b');
assert(options.args_[2]).equalTo('c');
assert(options.args_[3]).equalTo(1);
assert(options.args_[4]).equalTo(2);
assert(options.args_[5]).equalTo(3);
var json = options.serialize();
assert(json.args.length).equalTo(6);
assert(json.args[0]).equalTo('a');
assert(json.args[1]).equalTo('b');
assert(json.args[2]).equalTo('c');
assert(json.args[3]).equalTo(1);
assert(json.args[4]).equalTo(2);
assert(json.args[5]).equalTo(3);
});
});

Expand Down

0 comments on commit 9805a70

Please sign in to comment.