Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
style(jshint): update all style to work with new jshint config
Browse files Browse the repository at this point in the history
  • Loading branch information
juliemr committed Apr 25, 2014
1 parent 47d7636 commit 35dcea0
Show file tree
Hide file tree
Showing 21 changed files with 71 additions and 73 deletions.
1 change: 0 additions & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ process.argv.slice(2).forEach(function(arg) {

var util = require('util');
var path = require('path');
var child = require('child_process');
var fs = require('fs');
var optimist = require('optimist').
usage('Usage: protractor [options] [configFile]\n' +
Expand Down
13 changes: 6 additions & 7 deletions lib/clientsidescripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* inside scripts.
*/

/* jshint browser: true */
// jshint browser: true
// jshint shadow: true
/* global angular */
/* jshint shadow: true */
var clientSideScripts = exports;

/**
Expand Down Expand Up @@ -139,7 +139,6 @@ clientSideScripts.findBindings = function(binding, using) {
for (var i = 0; i < repeatElems.length; ++i) {
if (repeatElems[i].getAttribute(attr).indexOf(repeater) != -1) {
var elem = repeatElems[i];
var row = [];
while (elem.nodeType != 8 ||
elem.nodeValue.indexOf(repeater) == -1) {
rows.push(elem);
Expand Down Expand Up @@ -213,7 +212,7 @@ clientSideScripts.findRepeaterElement = function(repeater, index, binding, using
}
if (multiRow) {
for (var i = 0; i < multiRow.length; ++i) {
rowElem = multiRow[i];
var rowElem = multiRow[i];
if (rowElem.className.indexOf('ng-binding') != -1) {
bindings.push(rowElem);
}
Expand Down Expand Up @@ -372,7 +371,7 @@ clientSideScripts.findByButtonText = function(searchText, using) {
for (var i = 0; i < elements.length; ++i) {
var element = elements[i];
var elementText;
if (element.tagName.toLowerCase() == "button") {
if (element.tagName.toLowerCase() == 'button') {
elementText = element.innerText || element.textContent;
} else {
elementText = element.value;
Expand Down Expand Up @@ -400,7 +399,7 @@ clientSideScripts.findByPartialButtonText = function(searchText, using) {
for (var i = 0; i < elements.length; ++i) {
var element = elements[i];
var elementText;
if (element.tagName.toLowerCase() == "button") {
if (element.tagName.toLowerCase() == 'button') {
elementText = element.innerText || element.textContent;
} else {
elementText = element.value;
Expand Down Expand Up @@ -524,7 +523,7 @@ clientSideScripts.testForAngular = function(attempts, asyncCallback) {
callback([false, 'retries looking for angular exceeded']);
}
} else {
window.setTimeout(function() {check(n - 1)}, 1000);
window.setTimeout(function() {check(n - 1);}, 1000);
}
} catch (e) {
callback([false, e]);
Expand Down
6 changes: 4 additions & 2 deletions lib/configParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ try {
// Intentionally blank - ignore if LiveScript is not available.
}

module.exports = ConfigParser = function() {
var ConfigParser = function() {
// Default configuration.
this.config_= {
specs: [],
Expand Down Expand Up @@ -123,7 +123,7 @@ ConfigParser.getSpecs = function(config) {
});

return specs;
}
};

/**
* Add the options in the parameter config to this runner instance.
Expand Down Expand Up @@ -190,3 +190,5 @@ ConfigParser.prototype.addConfig = function(argv) {
ConfigParser.prototype.getConfig = function() {
return this.config_;
};

module.exports = ConfigParser;
4 changes: 2 additions & 2 deletions lib/driverProviders/chrome.dp.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ ChromeDriverProvider.prototype.getDriver = function() {
};

// new instance w/ each include
module.exports = (function(config) {
module.exports = function(config) {
return new ChromeDriverProvider(config);
});
};
6 changes: 3 additions & 3 deletions lib/driverProviders/hosted.dp.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ HostedDriverProvider.prototype.setupEnv = function() {
* @return {q.promise} A promise which will resolve when the environment
* is down.
*/
HostedDriverProvider.prototype.teardownEnv = function(runner) {
HostedDriverProvider.prototype.teardownEnv = function() {
var deferred = q.defer();
this.driver_.quit().then(function() {
deferred.resolve();
Expand All @@ -57,6 +57,6 @@ HostedDriverProvider.prototype.getDriver = function() {
};

// new instance w/ each include
module.exports = (function(config) {
module.exports = function(config) {
return new HostedDriverProvider(config);
});
};
4 changes: 2 additions & 2 deletions lib/driverProviders/local.dp.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ LocalDriverProvider.prototype.getDriver = function() {
};

// new instance w/ each include
module.exports = (function(config) {
module.exports = function(config) {
return new LocalDriverProvider(config);
});
};
4 changes: 2 additions & 2 deletions lib/driverProviders/sauce.dp.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ SauceDriverProvider.prototype.getDriver = function() {
};

// new instance w/ each include
module.exports = (function(config) {
module.exports = function(config) {
return new SauceDriverProvider(config);
});
};
15 changes: 6 additions & 9 deletions lib/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@
*/
'use strict';

var util = require('util'),
path = require('path'),
child = require('child_process'),
var child = require('child_process'),
ConfigParser = require('./configParser');

var launcherPrefix = '[launcher] '
var launcherPrefix = '[launcher] ';

var log_ = function(stuff) {
console.log(launcherPrefix + stuff);
}
};

var noLineLog_ = function(stuff) {
process.stdout.write(launcherPrefix + stuff);
}
};

var reportHeader_ = function(driverInstance) {
var capability = driverInstance.capability;
Expand All @@ -36,7 +34,6 @@ var reportHeader_ = function(driverInstance) {
outputHeader += ')' + eol;
outputHeader += '------------------------------------' + eol;


console.log(outputHeader);
};

Expand Down Expand Up @@ -146,7 +143,7 @@ var init = function(configFile, additionalConfig) {
driverInstances.forEach(function(driverInstance) {

driverInstance.process = child.fork(
__dirname + "/runFromLauncher.js",
__dirname + '/runFromLauncher.js',
process.argv.slice(2),
{silent: true, cwd: process.cwd()});

Expand Down Expand Up @@ -182,7 +179,7 @@ var init = function(configFile, additionalConfig) {
});

// exit handlers
driverInstance.process.on('exit', function(code, signal) {
driverInstance.process.on('exit', function(code) {
if (code) {
log_('Runner Process Exited With Error Code: ' + code);
launcherExitCode = 1;
Expand Down
27 changes: 14 additions & 13 deletions lib/protractor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
var url = require('url');
var util = require('util');
var path = require('path');
var webdriver = require('selenium-webdriver');

var clientSideScripts = require('./clientsidescripts.js');
Expand Down Expand Up @@ -607,6 +605,8 @@ Protractor.prototype.waitForAngular = function() {
* @return {webdriver.WebElement} the wrapped web element.
*/
Protractor.prototype.wrapWebElement = function(element) {
// We want to be able to used varArgs in function signatures for clarity.
// jshint unused: false
var thisPtor = this;
// Before any of the WebElement functions, Protractor will wait to make sure
// Angular is synced up.
Expand Down Expand Up @@ -642,7 +642,7 @@ Protractor.prototype.wrapWebElement = function(element) {
* @return {!webdriver.WebElement}
*/
element.$ = function(selector) {
var locator = protractor.By.css(selector);
var locator = thisPtor.By.css(selector);
return this.findElement(locator);
};

Expand Down Expand Up @@ -689,7 +689,7 @@ Protractor.prototype.wrapWebElement = function(element) {
* array of the located {@link webdriver.WebElement}s.
*/
element.$$ = function(selector) {
var locator = protractor.By.css(selector);
var locator = thisPtor.By.css(selector);
return this.findElements(locator);
};

Expand Down Expand Up @@ -882,7 +882,7 @@ Protractor.prototype.get = function(destination, opt_timeout) {
if (!hasAngular) {
var message = arr[1];
throw new Error('Angular could not be found on the page ' +
destination + " : " + message);
destination + ' : ' + message);
}
};

Expand All @@ -896,17 +896,17 @@ Protractor.prototype.get = function(destination, opt_timeout) {
// At this point, Angular will pause for us, until angular.resumeBootstrap
// is called.
for (var i = 0; i < this.moduleScripts_.length; ++i) {
name = this.moduleNames_[i];
var name = this.moduleNames_[i];
this.driver.executeScript(this.moduleScripts_[i]).
then(null, function(err) {
throw 'Error wile running module script ' + name +
': ' + err.message;
});
}

return this.driver.executeScript(function() {
angular.resumeBootstrap(arguments[0]);
}, this.moduleNames_);
return this.driver.executeScript(
'angular.resumeBootstrap(arguments[0]);',
this.moduleNames_);
};

/**
Expand All @@ -928,7 +928,7 @@ Protractor.prototype.refresh = function(opt_timeout) {
}

return self.driver.executeScript('return window.location.href').then(function(href) {
return self.get(href, opt_timeout);
return self.get(href, timeout);
});
};

Expand All @@ -940,7 +940,7 @@ Protractor.prototype.navigate = function() {
var nav = this.driver.navigate();
mixin(nav, this, 'refresh');
return nav;
}
};

/**
* Browse to another page using in-page navigation.
Expand Down Expand Up @@ -987,6 +987,7 @@ Protractor.prototype.getLocationAbsUrl = function() {
* debugger.
*/
Protractor.prototype.debugger = function() {
// jshint debug: true
var clientSideScriptsList = [];
for (var script in clientSideScripts) {
clientSideScriptsList.push(
Expand Down Expand Up @@ -1051,7 +1052,7 @@ Protractor.prototype.pause = function() {
if (descriptions[i].stack.length) {
asString += '\n |---' + descriptions[i].stack.join('\n |---');
}
if (!(i == descriptions.length - 1)) {
if (i != (descriptions.length - 1)) {
asString += '\n';
}
}
Expand All @@ -1069,7 +1070,7 @@ Protractor.prototype.pause = function() {
fork(__dirname + '/wddebugger.js', ['localhost:5858']);
process.on('exit', function() {
nodedebug.kill('SIGTERM');
})
});
});
flow.timeout(1000, 'waiting for debugger to attach');
};
Expand Down
2 changes: 0 additions & 2 deletions lib/runFromLauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
var ConfigParser = require('./configParser');
var Runner = require('./runner');

var config, argv;

process.on('message', function(m) {
switch (m.command) {
case 'run':
Expand Down
6 changes: 3 additions & 3 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ var protractor = require('./protractor'),
ConfigParser = require('./configParser'),
path = require('path'),
util = require('util'),
fs = require('fs'),
q = require('q'),
EventEmitter = require('events').EventEmitter;

Expand Down Expand Up @@ -63,6 +62,7 @@ Runner.prototype.runJasmine_ = function(specs, done) {
self = this;

require('../jasminewd');
/* global jasmine */

var RunnerReporter = function(emitter) {
this.emitter = emitter;
Expand Down Expand Up @@ -215,13 +215,13 @@ Runner.prototype.runCucumber_ = function(specs, done) {
execOptions.push(self.config_.cucumberOpts.format);
}
}
cucumber = Cucumber.Cli(execOptions);
global.cucumber = Cucumber.Cli(execOptions);

webdriver.promise.controlFlow().execute(function() {
self.runTestPreparers_();
}, 'run test preparers').then(function() {

cucumber.run(function(succeeded) {
global.cucumber.run(function(succeeded) {
if (self.config_.onComplete) {
self.config_.onComplete();
}
Expand Down
8 changes: 5 additions & 3 deletions lib/wddebugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ var repl = require('repl');
* at a time.
*/

// Leave in err, res function parameters.
// jshint unused: false
var baseDebugger = require('_debugger');

var client = new baseDebugger.Client();
Expand All @@ -23,7 +25,7 @@ var resume = function() {
resumeReplCallback();
}
resumeReplCallback = null;
}
};


var debugStepperEval = function(cmd, context, filename, callback) {
Expand All @@ -33,7 +35,7 @@ var debugStepperEval = function(cmd, context, filename, callback) {
// named 'c', 's', etc to the REPL context. They have getters which
// perform the desired function, and the callback is stored for later use.
// Think about whether this is a better pattern.
var cmd = cmd.slice(1, cmd.length - 2);
cmd = cmd.slice(1, cmd.length - 2);
switch (cmd) {
case 'c':
resumeReplCallback = callback;
Expand Down Expand Up @@ -80,7 +82,7 @@ var debugStepperEval = function(cmd, context, filename, callback) {
callback(null, undefined);
break;
}
}
};

var replOpts = {
prompt: 'wd-debug> ',
Expand Down
Loading

0 comments on commit 35dcea0

Please sign in to comment.