aboutsummaryrefslogtreecommitdiffstats
path: root/src/ngScenario
diff options
context:
space:
mode:
authorVojta Jina2013-10-22 14:41:21 -0700
committerVojta Jina2013-10-22 15:32:41 -0700
commitf2fab498303e00d199cb3d19a008670e214d5c10 (patch)
tree3aa88fdb1f63bbed45c7541232a0fdfac226c126 /src/ngScenario
parent934a95d3ef3f72dfc37b0b564624cb4a1286d4f4 (diff)
downloadangular.js-f2fab498303e00d199cb3d19a008670e214d5c10.tar.bz2
style: make jshint happy
Diffstat (limited to 'src/ngScenario')
-rw-r--r--src/ngScenario/ObjectModel.js7
-rw-r--r--src/ngScenario/Scenario.js9
-rw-r--r--src/ngScenario/SpecRunner.js3
-rw-r--r--src/ngScenario/angular-bootstrap.js2
-rw-r--r--src/ngScenario/browserTrigger.js10
-rw-r--r--src/ngScenario/dsl.js214
6 files changed, 134 insertions, 111 deletions
diff --git a/src/ngScenario/ObjectModel.js b/src/ngScenario/ObjectModel.js
index 47ee936b..14672080 100644
--- a/src/ngScenario/ObjectModel.js
+++ b/src/ngScenario/ObjectModel.js
@@ -66,7 +66,7 @@ angular.scenario.ObjectModel = function(runner) {
runner.on('StepBegin', function(spec, step) {
var it = self.getSpec(spec.id);
- var step = new angular.scenario.ObjectModel.Step(step.name);
+ step = new angular.scenario.ObjectModel.Step(step.name);
it.steps.push(step);
// forward the event
@@ -140,8 +140,9 @@ angular.scenario.ObjectModel.prototype.on = function(eventName, listener) {
*/
angular.scenario.ObjectModel.prototype.emit = function(eventName) {
var self = this,
- args = Array.prototype.slice.call(arguments, 1),
- eventName = eventName.toLowerCase();
+ args = Array.prototype.slice.call(arguments, 1);
+
+ eventName = eventName.toLowerCase();
if (this.listeners[eventName]) {
angular.forEach(this.listeners[eventName], function(listener) {
diff --git a/src/ngScenario/Scenario.js b/src/ngScenario/Scenario.js
index dda9a9e3..9a30d8a9 100644
--- a/src/ngScenario/Scenario.js
+++ b/src/ngScenario/Scenario.js
@@ -39,6 +39,7 @@ angular.scenario.output = angular.scenario.output || function(name, fn) {
*/
angular.scenario.dsl = angular.scenario.dsl || function(name, fn) {
angular.scenario.dsl[name] = function() {
+ /* jshint -W040 *//* The dsl binds `this` for us when calling chained functions */
function executeStatement(statement, args) {
var result = statement.apply(this, args);
if (angular.isFunction(result) || result instanceof angular.scenario.Future)
@@ -270,15 +271,15 @@ _jQuery.fn.bindings = function(windowJquery, bindExp) {
if (actualExp) {
actualExp = actualExp.replace(/\s/g, '');
if (actualExp == bindExp) return true;
- if (actualExp.indexOf(bindExp) == 0) {
+ if (actualExp.indexOf(bindExp) === 0) {
return actualExp.charAt(bindExp.length) == '|';
}
}
- }
+ };
} else if (bindExp) {
match = function(actualExp) {
return actualExp && bindExp.exec(actualExp);
- }
+ };
} else {
match = function(actualExp) {
return !!actualExp;
@@ -290,7 +291,7 @@ _jQuery.fn.bindings = function(windowJquery, bindExp) {
}
function push(value) {
- if (value == undefined) {
+ if (value === undefined) {
value = '';
} else if (typeof value != 'string') {
value = angular.toJson(value);
diff --git a/src/ngScenario/SpecRunner.js b/src/ngScenario/SpecRunner.js
index d15912d9..56a92b9a 100644
--- a/src/ngScenario/SpecRunner.js
+++ b/src/ngScenario/SpecRunner.js
@@ -18,7 +18,8 @@ angular.scenario.SpecRunner = function() {
* based on the describe nesting.
*
* @param {Object} spec A spec object
- * @param {function()} specDone function that is called when the spec finishes. Function(error, index)
+ * @param {function()} specDone function that is called when the spec finishes,
+ * of the form `Function(error, index)`
*/
angular.scenario.SpecRunner.prototype.run = function(spec, specDone) {
var self = this;
diff --git a/src/ngScenario/angular-bootstrap.js b/src/ngScenario/angular-bootstrap.js
index a0012ff7..d765dc66 100644
--- a/src/ngScenario/angular-bootstrap.js
+++ b/src/ngScenario/angular-bootstrap.js
@@ -1,5 +1,7 @@
'use strict';
+/* jshint -W060 */ /* we really do want to write to the document here */
+
(function(previousOnLoad){
var prefix = (function() {
var filename = /(.*\/)angular-bootstrap.js(#(.*))?/;
diff --git a/src/ngScenario/browserTrigger.js b/src/ngScenario/browserTrigger.js
index c614218d..f74a04c1 100644
--- a/src/ngScenario/browserTrigger.js
+++ b/src/ngScenario/browserTrigger.js
@@ -20,8 +20,8 @@
*
* @param {Object} element Either a wrapped jQuery/jqLite node or a DOMElement
* @param {string} eventType Optional event type
- * @param {Object=} eventData An optional object which contains additional event data (such as x,y coordinates, keys, etc...) that
- * are passed into the event when triggered
+ * @param {Object=} eventData An optional object which contains additional event data (such as x,y
+ * coordinates, keys, etc...) that are passed into the event when triggered
*/
window.browserTrigger = function browserTrigger(element, eventType, eventData) {
if (element && !element.nodeName) element = element[0];
@@ -124,8 +124,8 @@
evnt = document.createEvent('MouseEvents');
x = x || 0;
y = y || 0;
- evnt.initMouseEvent(eventType, true, true, window, 0, x, y, x, y, pressed('ctrl'), pressed('alt'),
- pressed('shift'), pressed('meta'), 0, element);
+ evnt.initMouseEvent(eventType, true, true, window, 0, x, y, x, y, pressed('ctrl'),
+ pressed('alt'), pressed('shift'), pressed('meta'), 0, element);
}
/* we're unable to change the timeStamp value directly so this
@@ -155,5 +155,5 @@
return finalProcessDefault;
}
- }
+ };
}());
diff --git a/src/ngScenario/dsl.js b/src/ngScenario/dsl.js
index a70f9aa8..50d20c95 100644
--- a/src/ngScenario/dsl.js
+++ b/src/ngScenario/dsl.js
@@ -179,12 +179,13 @@ angular.scenario.dsl('using', function() {
*/
angular.scenario.dsl('binding', function() {
return function(name) {
- return this.addFutureAction("select binding '" + name + "'", function($window, $document, done) {
- var values = $document.elements().bindings($window.angular.element, name);
- if (!values.length) {
- return done("Binding selector '" + name + "' did not match.");
- }
- done(null, values[0]);
+ return this.addFutureAction("select binding '" + name + "'",
+ function($window, $document, done) {
+ var values = $document.elements().bindings($window.angular.element, name);
+ if (!values.length) {
+ return done("Binding selector '" + name + "' did not match.");
+ }
+ done(null, values[0]);
});
};
});
@@ -201,28 +202,31 @@ angular.scenario.dsl('input', function() {
var supportInputEvent = 'oninput' in document.createElement('div') && msie != 9;
chain.enter = function(value, event) {
- return this.addFutureAction("input '" + this.name + "' enter '" + value + "'", function($window, $document, done) {
- var input = $document.elements('[ng\\:model="$1"]', this.name).filter(':input');
- input.val(value);
- input.trigger(event || (supportInputEvent ? 'input' : 'change'));
- done();
+ return this.addFutureAction("input '" + this.name + "' enter '" + value + "'",
+ function($window, $document, done) {
+ var input = $document.elements('[ng\\:model="$1"]', this.name).filter(':input');
+ input.val(value);
+ input.trigger(event || (supportInputEvent ? 'input' : 'change'));
+ done();
});
};
chain.check = function() {
- return this.addFutureAction("checkbox '" + this.name + "' toggle", function($window, $document, done) {
- var input = $document.elements('[ng\\:model="$1"]', this.name).filter(':checkbox');
- input.trigger('click');
- done();
+ return this.addFutureAction("checkbox '" + this.name + "' toggle",
+ function($window, $document, done) {
+ var input = $document.elements('[ng\\:model="$1"]', this.name).filter(':checkbox');
+ input.trigger('click');
+ done();
});
};
chain.select = function(value) {
- return this.addFutureAction("radio button '" + this.name + "' toggle '" + value + "'", function($window, $document, done) {
- var input = $document.
- elements('[ng\\:model="$1"][value="$2"]', this.name, value).filter(':radio');
- input.trigger('click');
- done();
+ return this.addFutureAction("radio button '" + this.name + "' toggle '" + value + "'",
+ function($window, $document, done) {
+ var input = $document.
+ elements('[ng\\:model="$1"][value="$2"]', this.name, value).filter(':radio');
+ input.trigger('click');
+ done();
});
};
@@ -244,33 +248,37 @@ angular.scenario.dsl('input', function() {
* Usage:
* repeater('#products table', 'Product List').count() number of rows
* repeater('#products table', 'Product List').row(1) all bindings in row as an array
- * repeater('#products table', 'Product List').column('product.name') all values across all rows in an array
+ * repeater('#products table', 'Product List').column('product.name') all values across all rows
+ * in an array
*/
angular.scenario.dsl('repeater', function() {
var chain = {};
chain.count = function() {
- return this.addFutureAction("repeater '" + this.label + "' count", function($window, $document, done) {
- try {
- done(null, $document.elements().length);
- } catch (e) {
- done(null, 0);
- }
+ return this.addFutureAction("repeater '" + this.label + "' count",
+ function($window, $document, done) {
+ try {
+ done(null, $document.elements().length);
+ } catch (e) {
+ done(null, 0);
+ }
});
};
chain.column = function(binding) {
- return this.addFutureAction("repeater '" + this.label + "' column '" + binding + "'", function($window, $document, done) {
- done(null, $document.elements().bindings($window.angular.element, binding));
+ return this.addFutureAction("repeater '" + this.label + "' column '" + binding + "'",
+ function($window, $document, done) {
+ done(null, $document.elements().bindings($window.angular.element, binding));
});
};
chain.row = function(index) {
- return this.addFutureAction("repeater '" + this.label + "' row '" + index + "'", function($window, $document, done) {
- var matches = $document.elements().slice(index, index + 1);
- if (!matches.length)
- return done('row ' + index + ' out of bounds');
- done(null, matches.bindings($window.angular.element));
+ return this.addFutureAction("repeater '" + this.label + "' row '" + index + "'",
+ function($window, $document, done) {
+ var matches = $document.elements().slice(index, index + 1);
+ if (!matches.length)
+ return done('row ' + index + ' out of bounds');
+ done(null, matches.bindings($window.angular.element));
});
};
@@ -289,36 +297,38 @@ angular.scenario.dsl('select', function() {
var chain = {};
chain.option = function(value) {
- return this.addFutureAction("select '" + this.name + "' option '" + value + "'", function($window, $document, done) {
- var select = $document.elements('select[ng\\:model="$1"]', this.name);
- var option = select.find('option[value="' + value + '"]');
- if (option.length) {
- select.val(value);
- } else {
- option = select.find('option').filter(function(){
- return _jQuery(this).text() === value;
- });
- if (!option.length) {
- option = select.find('option:contains("' + value + '")');
- }
+ return this.addFutureAction("select '" + this.name + "' option '" + value + "'",
+ function($window, $document, done) {
+ var select = $document.elements('select[ng\\:model="$1"]', this.name);
+ var option = select.find('option[value="' + value + '"]');
if (option.length) {
- select.val(option.val());
+ select.val(value);
} else {
- return done("option '" + value + "' not found");
+ option = select.find('option').filter(function(){
+ return _jQuery(this).text() === value;
+ });
+ if (!option.length) {
+ option = select.find('option:contains("' + value + '")');
+ }
+ if (option.length) {
+ select.val(option.val());
+ } else {
+ return done("option '" + value + "' not found");
+ }
}
- }
- select.trigger('change');
- done();
+ select.trigger('change');
+ done();
});
};
chain.options = function() {
var values = arguments;
- return this.addFutureAction("select '" + this.name + "' options '" + values + "'", function($window, $document, done) {
- var select = $document.elements('select[multiple][ng\\:model="$1"]', this.name);
- select.val(values);
- select.trigger('change');
- done();
+ return this.addFutureAction("select '" + this.name + "' options '" + values + "'",
+ function($window, $document, done) {
+ var select = $document.elements('select[multiple][ng\\:model="$1"]', this.name);
+ select.val(values);
+ select.trigger('change');
+ done();
});
};
@@ -350,74 +360,81 @@ angular.scenario.dsl('element', function() {
var chain = {};
chain.count = function() {
- return this.addFutureAction("element '" + this.label + "' count", function($window, $document, done) {
- try {
- done(null, $document.elements().length);
- } catch (e) {
- done(null, 0);
- }
+ return this.addFutureAction("element '" + this.label + "' count",
+ function($window, $document, done) {
+ try {
+ done(null, $document.elements().length);
+ } catch (e) {
+ done(null, 0);
+ }
});
};
chain.click = function() {
- return this.addFutureAction("element '" + this.label + "' click", function($window, $document, done) {
- var elements = $document.elements();
- var href = elements.attr('href');
- var eventProcessDefault = elements.trigger('click')[0];
+ return this.addFutureAction("element '" + this.label + "' click",
+ function($window, $document, done) {
+ var elements = $document.elements();
+ var href = elements.attr('href');
+ var eventProcessDefault = elements.trigger('click')[0];
- if (href && elements[0].nodeName.toUpperCase() === 'A' && eventProcessDefault) {
- this.application.navigateTo(href, function() {
+ if (href && elements[0].nodeName.toUpperCase() === 'A' && eventProcessDefault) {
+ this.application.navigateTo(href, function() {
+ done();
+ }, done);
+ } else {
done();
- }, done);
- } else {
- done();
- }
+ }
});
};
chain.dblclick = function() {
- return this.addFutureAction("element '" + this.label + "' dblclick", function($window, $document, done) {
- var elements = $document.elements();
- var href = elements.attr('href');
- var eventProcessDefault = elements.trigger('dblclick')[0];
+ return this.addFutureAction("element '" + this.label + "' dblclick",
+ function($window, $document, done) {
+ var elements = $document.elements();
+ var href = elements.attr('href');
+ var eventProcessDefault = elements.trigger('dblclick')[0];
- if (href && elements[0].nodeName.toUpperCase() === 'A' && eventProcessDefault) {
- this.application.navigateTo(href, function() {
+ if (href && elements[0].nodeName.toUpperCase() === 'A' && eventProcessDefault) {
+ this.application.navigateTo(href, function() {
+ done();
+ }, done);
+ } else {
done();
- }, done);
- } else {
- done();
- }
+ }
});
};
chain.mouseover = function() {
- return this.addFutureAction("element '" + this.label + "' mouseover", function($window, $document, done) {
- var elements = $document.elements();
- elements.trigger('mouseover');
- done();
+ return this.addFutureAction("element '" + this.label + "' mouseover",
+ function($window, $document, done) {
+ var elements = $document.elements();
+ elements.trigger('mouseover');
+ done();
});
};
chain.mousedown = function() {
- return this.addFutureAction("element '" + this.label + "' mousedown", function($window, $document, done) {
- var elements = $document.elements();
- elements.trigger('mousedown');
- done();
+ return this.addFutureAction("element '" + this.label + "' mousedown",
+ function($window, $document, done) {
+ var elements = $document.elements();
+ elements.trigger('mousedown');
+ done();
});
};
chain.mouseup = function() {
- return this.addFutureAction("element '" + this.label + "' mouseup", function($window, $document, done) {
- var elements = $document.elements();
- elements.trigger('mouseup');
- done();
+ return this.addFutureAction("element '" + this.label + "' mouseup",
+ function($window, $document, done) {
+ var elements = $document.elements();
+ elements.trigger('mouseup');
+ done();
});
};
chain.query = function(fn) {
- return this.addFutureAction('element ' + this.label + ' custom query', function($window, $document, done) {
- fn.call(this, $document.elements(), done);
+ return this.addFutureAction('element ' + this.label + ' custom query',
+ function($window, $document, done) {
+ fn.call(this, $document.elements(), done);
});
};
@@ -426,7 +443,8 @@ angular.scenario.dsl('element', function() {
var args = arguments,
futureName = (args.length == 1)
? "element '" + this.label + "' get " + methodName + " '" + name + "'"
- : "element '" + this.label + "' set " + methodName + " '" + name + "' to " + "'" + value + "'";
+ : "element '" + this.label + "' set " + methodName + " '" + name + "' to " + "'" +
+ value + "'";
return this.addFutureAction(futureName, function($window, $document, done) {
var element = $document.elements();
@@ -438,7 +456,7 @@ angular.scenario.dsl('element', function() {
angular.forEach(VALUE_METHODS, function(methodName) {
chain[methodName] = function(value) {
var args = arguments,
- futureName = (args.length == 0)
+ futureName = (args.length === 0)
? "element '" + this.label + "' " + methodName
: "element '" + this.label + "' set " + methodName + " to '" + value + "'";