style(*): add rule requireSpacesInFunction beforeOpeningCurlyBrace

This rule enforces a space after the curly brace
for function declarations, anonymous function expressions,
and named function expressions.
This commit is contained in:
Henry Zhu
2014-10-20 21:59:40 -04:00
committed by Caitlin Potter
parent 922162853b
commit 7f65f97919
72 changed files with 324 additions and 321 deletions

View File

@@ -16,5 +16,8 @@
"disallowTrailingComma": true,
"disallowTrailingWhitespace": true,
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"],
"requireSpacesInFunction": {
"beforeOpeningCurlyBrace": true
},
"validateParameterSeparator": ", "
}

View File

@@ -123,7 +123,7 @@ var VALIDITY_STATE_PROPERTY = 'validity';
* @param {string} string String to be converted to lowercase.
* @returns {string} Lowercased string.
*/
var lowercase = function(string){return isString(string) ? string.toLowerCase() : string;};
var lowercase = function(string) {return isString(string) ? string.toLowerCase() : string;};
var hasOwnProperty = Object.prototype.hasOwnProperty;
/**
@@ -136,7 +136,7 @@ var hasOwnProperty = Object.prototype.hasOwnProperty;
* @param {string} string String to be converted to uppercase.
* @returns {string} Uppercased string.
*/
var uppercase = function(string){return isString(string) ? string.toUpperCase() : string;};
var uppercase = function(string) {return isString(string) ? string.toUpperCase() : string;};
var manualLowercase = function(s) {
@@ -419,7 +419,7 @@ function valueFn(value) {return function() {return value;};}
* @param {*} value Reference to check.
* @returns {boolean} True if `value` is undefined.
*/
function isUndefined(value){return typeof value === 'undefined';}
function isUndefined(value) {return typeof value === 'undefined';}
/**
@@ -434,7 +434,7 @@ function isUndefined(value){return typeof value === 'undefined';}
* @param {*} value Reference to check.
* @returns {boolean} True if `value` is defined.
*/
function isDefined(value){return typeof value !== 'undefined';}
function isDefined(value) {return typeof value !== 'undefined';}
/**
@@ -450,7 +450,7 @@ function isDefined(value){return typeof value !== 'undefined';}
* @param {*} value Reference to check.
* @returns {boolean} True if `value` is an `Object` but not `null`.
*/
function isObject(value){
function isObject(value) {
// http://jsperf.com/isobject4
return value !== null && typeof value === 'object';
}
@@ -468,7 +468,7 @@ function isObject(value){
* @param {*} value Reference to check.
* @returns {boolean} True if `value` is a `String`.
*/
function isString(value){return typeof value === 'string';}
function isString(value) {return typeof value === 'string';}
/**
@@ -483,7 +483,7 @@ function isString(value){return typeof value === 'string';}
* @param {*} value Reference to check.
* @returns {boolean} True if `value` is a `Number`.
*/
function isNumber(value){return typeof value === 'number';}
function isNumber(value) {return typeof value === 'number';}
/**
@@ -529,7 +529,7 @@ var isArray = Array.isArray;
* @param {*} value Reference to check.
* @returns {boolean} True if `value` is a `Function`.
*/
function isFunction(value){return typeof value === 'function';}
function isFunction(value) {return typeof value === 'function';}
/**

View File

@@ -110,7 +110,7 @@ var version = {
};
function publishExternalAPI(angular){
function publishExternalAPI(angular) {
extend(angular, {
'bootstrap': bootstrap,
'copy': copy,

View File

@@ -705,7 +705,7 @@ function createInjector(modulesToLoad, strictDi) {
////////////////////////////////////
// Module Loading
////////////////////////////////////
function loadModules(modulesToLoad){
function loadModules(modulesToLoad) {
var runBlocks = [], moduleFn;
forEach(modulesToLoad, function(module) {
if (loadedModules.get(module)) return;

View File

@@ -251,7 +251,7 @@ function jqLiteClone(element) {
return element.cloneNode(true);
}
function jqLiteDealoc(element, onlyDescendants){
function jqLiteDealoc(element, onlyDescendants) {
if (!onlyDescendants) jqLiteRemoveData(element);
if (element.querySelectorAll) {
@@ -493,7 +493,7 @@ var JQLitePrototype = JQLite.prototype = {
},
toString: function() {
var value = [];
forEach(this, function(e){ value.push('' + e);});
forEach(this, function(e) { value.push('' + e);});
return '[' + value.join(', ') + ']';
},
@@ -584,7 +584,7 @@ forEach({
}
},
attr: function(element, name, value){
attr: function(element, name, value) {
var lowercasedName = lowercase(name);
if (BOOLEAN_ATTR[lowercasedName]) {
if (isDefined(value)) {
@@ -658,7 +658,7 @@ forEach({
},
empty: jqLiteEmpty
}, function(fn, name){
}, function(fn, name) {
/**
* Properties: writes return selection, reads return first value
*/
@@ -766,7 +766,7 @@ function createEventHandler(element, events) {
forEach({
removeData: jqLiteRemoveData,
on: function jqLiteOn(element, type, fn, unsupported){
on: function jqLiteOn(element, type, fn, unsupported) {
if (isDefined(unsupported)) throw jqLiteMinErr('onargs', 'jqLite#on() does not support the `selector` or `eventData` parameters');
// Do not add event handlers to non-elements because they will not be cleaned up.
@@ -836,7 +836,7 @@ forEach({
replaceWith: function(element, replaceNode) {
var index, parent = element.parentNode;
jqLiteDealoc(element);
forEach(new JQLite(replaceNode), function(node){
forEach(new JQLite(replaceNode), function(node) {
if (index) {
parent.insertBefore(node, index.nextSibling);
} else {
@@ -848,7 +848,7 @@ forEach({
children: function(element) {
var children = [];
forEach(element.childNodes, function(element){
forEach(element.childNodes, function(element) {
if (element.nodeType === NODE_TYPE_ELEMENT)
children.push(element);
});
@@ -874,7 +874,7 @@ forEach({
prepend: function(element, node) {
if (element.nodeType === NODE_TYPE_ELEMENT) {
var index = element.firstChild;
forEach(new JQLite(node), function(child){
forEach(new JQLite(node), function(child) {
element.insertBefore(child, index);
});
}
@@ -911,7 +911,7 @@ forEach({
toggleClass: function(element, selector, condition) {
if (selector) {
forEach(selector.split(' '), function(className){
forEach(selector.split(' '), function(className) {
var classCondition = condition;
if (isUndefined(classCondition)) {
classCondition = !jqLiteHasClass(element, className);
@@ -976,7 +976,7 @@ forEach({
});
}
}
}, function(fn, name){
}, function(fn, name) {
/**
* chaining functions
*/

View File

@@ -1,6 +1,6 @@
'use strict';
function $$AsyncCallbackProvider(){
function $$AsyncCallbackProvider() {
this.$get = ['$$rAF', '$timeout', function($$rAF, $timeout) {
return $$rAF.supported
? function(fn) { return $$rAF(fn); }

View File

@@ -72,7 +72,7 @@ function Browser(window, document, $log, $sniffer) {
// force browser to execute all pollFns - this is needed so that cookies and other pollers fire
// at some deterministic time in respect to the test runner's actions. Leaving things up to the
// regular poller would result in flaky tests.
forEach(pollFns, function(pollFn){ pollFn(); });
forEach(pollFns, function(pollFn) { pollFn(); });
if (outstandingRequestCount === 0) {
callback();
@@ -114,7 +114,7 @@ function Browser(window, document, $log, $sniffer) {
*/
function startPoller(interval, setTimeout) {
(function check() {
forEach(pollFns, function(pollFn){ pollFn(); });
forEach(pollFns, function(pollFn) { pollFn(); });
pollTimeout = setTimeout(check, interval);
})();
}
@@ -449,9 +449,9 @@ function Browser(window, document, $log, $sniffer) {
}
function $BrowserProvider(){
function $BrowserProvider() {
this.$get = ['$window', '$log', '$sniffer', '$document',
function($window, $log, $sniffer, $document){
function($window, $log, $sniffer, $document) {
return new Browser($window, $document, $log, $sniffer);
}];
}

View File

@@ -1145,7 +1145,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
}
// We can not compile top level text elements since text nodes can be merged and we will
// not be able to attach scope data to them, so we will wrap them in <span>
forEach($compileNodes, function(node, index){
forEach($compileNodes, function(node, index) {
if (node.nodeType == NODE_TYPE_TEXT && node.nodeValue.match(/\S+/) /* non-empty */ ) {
$compileNodes[index] = jqLite(node).wrap('<span></span>').parent()[0];
}
@@ -1155,7 +1155,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
maxPriority, ignoreDirective, previousCompileContext);
compile.$$addScopeClass($compileNodes);
var namespace = null;
return function publicLinkFn(scope, cloneConnectFn, transcludeControllers, parentBoundTranscludeFn, futureParentElement){
return function publicLinkFn(scope, cloneConnectFn, transcludeControllers, parentBoundTranscludeFn, futureParentElement) {
assertArg(scope, 'scope');
if (!namespace) {
namespace = detectNamespaceForChildElements(futureParentElement);
@@ -2504,7 +2504,7 @@ function nodesetLinkingFn(
/* NodeList */ nodeList,
/* Element */ rootElement,
/* function(Function) */ boundTranscludeFn
){}
) {}
function directiveLinkingFn(
/* nodesetLinkingFn */ nodesetLinkingFn,
@@ -2512,7 +2512,7 @@ function directiveLinkingFn(
/* Node */ node,
/* Element */ rootElement,
/* function(Function) */ boundTranscludeFn
){}
) {}
function tokenDifference(str1, str2) {
var values = '',

View File

@@ -21,7 +21,7 @@ var htmlAnchorDirective = valueFn({
// SVGAElement does not use the href attribute, but rather the 'xlinkHref' attribute.
var href = toString.call(element.prop('href')) === '[object SVGAnimatedString]' ?
'xlink:href' : 'href';
element.on('click', function(event){
element.on('click', function(event) {
// if we have no href url, then don't navigate anywhere.
if (!element.attr(href)) {
event.preventDefault();

View File

@@ -162,7 +162,7 @@ var ngShowDirective = ['$animate', function($animate) {
restrict: 'A',
multiElement: true,
link: function(scope, element, attr) {
scope.$watch(attr.ngShow, function ngShowWatchAction(value){
scope.$watch(attr.ngShow, function ngShowWatchAction(value) {
// we're adding a temporary, animation-specific class for ng-hide since this way
// we can control when the element is actually displayed on screen without having
// to have a global/greedy CSS selector that breaks when other animations are run.
@@ -323,7 +323,7 @@ var ngHideDirective = ['$animate', function($animate) {
restrict: 'A',
multiElement: true,
link: function(scope, element, attr) {
scope.$watch(attr.ngHide, function ngHideWatchAction(value){
scope.$watch(attr.ngHide, function ngHideWatchAction(value) {
// The comment inside of the ngShowDirective explains why we add and
// remove a temporary class for the show/hide animation
$animate[value ? 'addClass' : 'removeClass'](element,NG_HIDE_CLASS, {

View File

@@ -25,8 +25,8 @@
</file>
</example>
*/
function $DocumentProvider(){
this.$get = ['$window', function(window){
function $DocumentProvider() {
this.$get = ['$window', function(window) {
return jqLite(window.document);
}];
}

View File

@@ -153,7 +153,7 @@ function filterFilter() {
}
}
var search = function(obj, text){
var search = function(obj, text) {
if (typeof text === 'string' && text.charAt(0) === '!') {
return !search(obj, text.substr(1));
}

View File

@@ -55,7 +55,7 @@
currencyFilter.$inject = ['$locale'];
function currencyFilter($locale) {
var formats = $locale.NUMBER_FORMATS;
return function(amount, currencySymbol, fractionSize){
return function(amount, currencySymbol, fractionSize) {
if (isUndefined(currencySymbol)) {
currencySymbol = formats.CURRENCY_SYM;
}
@@ -480,7 +480,7 @@ function dateFilter($locale) {
date = new Date(date.getTime());
date.setMinutes(date.getMinutes() + date.getTimezoneOffset());
}
forEach(parts, function(value){
forEach(parts, function(value) {
fn = DATE_FORMATS[value];
text += fn ? fn(date, $locale.DATETIME_FORMATS)
: value.replace(/(^'|'$)/g, '').replace(/''/g, "'");

View File

@@ -86,7 +86,7 @@
</file>
</example>
*/
function limitToFilter(){
function limitToFilter() {
return function(input, limit) {
if (isNumber(input)) input = input.toString();
if (!isArray(input) && !isString(input)) return input;

View File

@@ -116,12 +116,12 @@
</example>
*/
orderByFilter.$inject = ['$parse'];
function orderByFilter($parse){
function orderByFilter($parse) {
return function(array, sortPredicate, reverseOrder) {
if (!(isArrayLike(array))) return array;
sortPredicate = isArray(sortPredicate) ? sortPredicate: [sortPredicate];
if (sortPredicate.length === 0) { sortPredicate = ['+']; }
sortPredicate = sortPredicate.map(function(predicate){
sortPredicate = sortPredicate.map(function(predicate) {
var descending = false, get = predicate || identity;
if (isString(predicate)) {
if ((predicate.charAt(0) == '+' || predicate.charAt(0) == '-')) {
@@ -142,7 +142,7 @@ function orderByFilter($parse){
}, descending);
}
}
return reverseComparator(function(a, b){
return reverseComparator(function(a, b) {
return compare(get(a),get(b));
}, descending);
});
@@ -150,7 +150,7 @@ function orderByFilter($parse){
for (var i = 0; i < array.length; i++) { arrayCopy.push(array[i]); }
return arrayCopy.sort(reverseComparator(comparator, reverseOrder));
function comparator(o1, o2){
function comparator(o1, o2) {
for (var i = 0; i < sortPredicate.length; i++) {
var comp = sortPredicate[i](o1, o2);
if (comp !== 0) return comp;
@@ -159,10 +159,10 @@ function orderByFilter($parse){
}
function reverseComparator(comp, descending) {
return descending
? function(a, b){return comp(b,a);}
? function(a, b) {return comp(b,a);}
: comp;
}
function compare(v1, v2){
function compare(v1, v2) {
var t1 = typeof v1;
var t2 = typeof v2;
if (t1 == t2) {

View File

@@ -50,7 +50,7 @@ function $InterpolateProvider() {
* @param {string=} value new value to set the starting symbol to.
* @returns {string|self} Returns the symbol when used as getter and self if used as setter.
*/
this.startSymbol = function(value){
this.startSymbol = function(value) {
if (value) {
startSymbol = value;
return this;
@@ -68,7 +68,7 @@ function $InterpolateProvider() {
* @param {string=} value new value to set the ending symbol to.
* @returns {string|self} Returns the symbol when used as getter and self if used as setter.
*/
this.endSymbol = function(value){
this.endSymbol = function(value) {
if (value) {
endSymbol = value;
return this;

View File

@@ -10,7 +10,7 @@
*
* * `id` `{string}` locale id formatted as `languageId-countryId` (e.g. `en-us`)
*/
function $LocaleProvider(){
function $LocaleProvider() {
this.$get = function() {
return {
id: 'en-us',

View File

@@ -621,7 +621,7 @@ function locationGetterSetter(property, preprocess) {
* @description
* Use the `$locationProvider` to configure how the application deep linking paths are stored.
*/
function $LocationProvider(){
function $LocationProvider() {
var hashPrefix = '',
html5Mode = {
enabled: false,

View File

@@ -43,7 +43,7 @@
* @description
* Use the `$logProvider` to configure how the application logs messages
*/
function $LogProvider(){
function $LogProvider() {
var debug = true,
self = this;
@@ -63,7 +63,7 @@ function $LogProvider(){
}
};
this.$get = ['$window', function($window){
this.$get = ['$window', function($window) {
return {
/**
* @ngdoc method

View File

@@ -99,7 +99,7 @@ CONSTANTS['this'].sharedGetter = true;
//Operators - will be wrapped by binaryFn/unaryFn/assignment/filter
var OPERATORS = extend(createMap(), {
'+':function(self, locals, a, b){
'+':function(self, locals, a, b) {
a=a(self, locals); b=b(self, locals);
if (isDefined(a)) {
if (isDefined(b)) {
@@ -108,24 +108,24 @@ var OPERATORS = extend(createMap(), {
return a;
}
return isDefined(b)?b:undefined;},
'-':function(self, locals, a, b){
'-':function(self, locals, a, b) {
a=a(self, locals); b=b(self, locals);
return (isDefined(a)?a:0)-(isDefined(b)?b:0);
},
'*':function(self, locals, a, b){return a(self, locals)*b(self, locals);},
'/':function(self, locals, a, b){return a(self, locals)/b(self, locals);},
'%':function(self, locals, a, b){return a(self, locals)%b(self, locals);},
'===':function(self, locals, a, b){return a(self, locals)===b(self, locals);},
'!==':function(self, locals, a, b){return a(self, locals)!==b(self, locals);},
'==':function(self, locals, a, b){return a(self, locals)==b(self, locals);},
'!=':function(self, locals, a, b){return a(self, locals)!=b(self, locals);},
'<':function(self, locals, a, b){return a(self, locals)<b(self, locals);},
'>':function(self, locals, a, b){return a(self, locals)>b(self, locals);},
'<=':function(self, locals, a, b){return a(self, locals)<=b(self, locals);},
'>=':function(self, locals, a, b){return a(self, locals)>=b(self, locals);},
'&&':function(self, locals, a, b){return a(self, locals)&&b(self, locals);},
'||':function(self, locals, a, b){return a(self, locals)||b(self, locals);},
'!':function(self, locals, a){return !a(self, locals);},
'*':function(self, locals, a, b) {return a(self, locals)*b(self, locals);},
'/':function(self, locals, a, b) {return a(self, locals)/b(self, locals);},
'%':function(self, locals, a, b) {return a(self, locals)%b(self, locals);},
'===':function(self, locals, a, b) {return a(self, locals)===b(self, locals);},
'!==':function(self, locals, a, b) {return a(self, locals)!==b(self, locals);},
'==':function(self, locals, a, b) {return a(self, locals)==b(self, locals);},
'!=':function(self, locals, a, b) {return a(self, locals)!=b(self, locals);},
'<':function(self, locals, a, b) {return a(self, locals)<b(self, locals);},
'>':function(self, locals, a, b) {return a(self, locals)>b(self, locals);},
'<=':function(self, locals, a, b) {return a(self, locals)<=b(self, locals);},
'>=':function(self, locals, a, b) {return a(self, locals)>=b(self, locals);},
'&&':function(self, locals, a, b) {return a(self, locals)&&b(self, locals);},
'||':function(self, locals, a, b) {return a(self, locals)||b(self, locals);},
'!':function(self, locals, a) {return !a(self, locals);},
//Tokenized as operators but parsed as assignment/filters
'=':true,
@@ -479,7 +479,7 @@ Parser.prototype = {
return false;
},
expect: function(e1, e2, e3, e4){
expect: function(e1, e2, e3, e4) {
var token = this.peek(e1, e2, e3, e4);
if (token) {
this.tokens.shift();
@@ -488,7 +488,7 @@ Parser.prototype = {
return false;
},
consume: function(e1){
consume: function(e1) {
if (!this.expect(e1)) {
this.throwError('is unexpected, expecting [' + e1 + ']', this.peek());
}
@@ -610,7 +610,7 @@ Parser.prototype = {
if ((token = this.expect(':'))) {
var right = this.assignment();
return extend(function $parseTernary(self, locals){
return extend(function $parseTernary(self, locals) {
return left(self, locals) ? middle(self, locals) : right(self, locals);
}, {
constant: left.constant && middle.constant && right.constant

View File

@@ -1,6 +1,6 @@
'use strict';
function $$RAFProvider(){ //rAF
function $$RAFProvider() { //rAF
this.$get = ['$window', '$timeout', function($window, $timeout) {
var requestAnimationFrame = $window.requestAnimationFrame ||
$window.webkitRequestAnimationFrame ||

View File

@@ -67,7 +67,7 @@
* They also provide an event emission/broadcast and subscription facility. See the
* {@link guide/scope developer guide on scopes}.
*/
function $RootScopeProvider(){
function $RootScopeProvider() {
var TTL = 10;
var $rootScopeMinErr = minErr('$rootScope');
var lastDirtyWatch = null;

View File

@@ -41,6 +41,6 @@
</file>
</example>
*/
function $WindowProvider(){
function $WindowProvider() {
this.$get = valueFn(window);
}

View File

@@ -67,7 +67,7 @@ angular.mock.$Browser = function() {
self.defer = function(fn, delay) {
delay = delay || 0;
self.deferredFns.push({time:(self.defer.now + delay), fn:fn, id: self.deferredNextId});
self.deferredFns.sort(function(a, b){ return a.time - b.time;});
self.deferredFns.sort(function(a, b) { return a.time - b.time;});
return self.deferredNextId++;
};
@@ -135,7 +135,7 @@ angular.mock.$Browser.prototype = {
* run all fns in pollFns
*/
poll: function poll() {
angular.forEach(this.pollFns, function(pollFn){
angular.forEach(this.pollFns, function(pollFn) {
pollFn();
});
},
@@ -497,7 +497,7 @@ angular.mock.$IntervalProvider = function() {
id: nextRepeatId,
deferred: deferred
});
repeatFns.sort(function(a, b){ return a.nextTime - b.nextTime;});
repeatFns.sort(function(a, b) { return a.nextTime - b.nextTime;});
nextRepeatId++;
return promise;
@@ -546,7 +546,7 @@ angular.mock.$IntervalProvider = function() {
var task = repeatFns[0];
task.fn();
task.nextTime += task.delay;
repeatFns.sort(function(a, b){ return a.nextTime - b.nextTime;});
repeatFns.sort(function(a, b) { return a.nextTime - b.nextTime;});
}
return millis;
};

View File

@@ -30,7 +30,7 @@ function lookupDottedPath(obj, path) {
function shallowClearAndCopy(src, dst) {
dst = dst || {};
angular.forEach(dst, function(value, key){
angular.forEach(dst, function(value, key) {
delete dst[key];
});

View File

@@ -34,7 +34,7 @@ var ngRouteModule = angular.module('ngRoute', ['ng']).
* ## Dependencies
* Requires the {@link ngRoute `ngRoute`} module to be installed.
*/
function $RouteProvider(){
function $RouteProvider() {
function inherit(parent, extra) {
return angular.extend(new (angular.extend(function() {}, {prototype:parent}))(), extra);
}
@@ -183,7 +183,7 @@ function $RouteProvider(){
path = path
.replace(/([().])/g, '\\$1')
.replace(/(\/)?:(\w+)([\?\*])?/g, function(_, slash, key, option){
.replace(/(\/)?:(\w+)([\?\*])?/g, function(_, slash, key, option) {
var optional = option === '?' ? option : null;
var star = option === '*' ? option : null;
keys.push({ name: key, optional: !!optional });

View File

@@ -306,7 +306,7 @@ function htmlParser(html, handler) {
} else {
html = html.replace(new RegExp("(.*)<\\s*\\/\\s*" + stack.last() + "[^>]*>", 'i'),
function(all, text){
function(all, text) {
text = text.replace(COMMENT_REGEXP, "$1").replace(CDATA_REGEXP, "$1");
if (handler.chars) handler.chars(decodeEntities(text));
@@ -421,7 +421,7 @@ function encodeEntities(value) {
var low = value.charCodeAt(1);
return '&#' + (((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000) + ';';
}).
replace(NON_ALPHANUMERIC_REGEXP, function(value){
replace(NON_ALPHANUMERIC_REGEXP, function(value) {
return '&#' + value.charCodeAt(0) + ';';
}).
replace(/</g, '&lt;').
@@ -438,11 +438,11 @@ function encodeEntities(value) {
* comment: function(text) {}
* }
*/
function htmlSanitizeWriter(buf, uriValidator){
function htmlSanitizeWriter(buf, uriValidator) {
var ignore = false;
var out = angular.bind(buf, buf.push);
return {
start: function(tag, attrs, unary){
start: function(tag, attrs, unary) {
tag = angular.lowercase(tag);
if (!ignore && specialElements[tag]) {
ignore = tag;
@@ -450,7 +450,7 @@ function htmlSanitizeWriter(buf, uriValidator){
if (!ignore && validElements[tag] === true) {
out('<');
out(tag);
angular.forEach(attrs, function(value, key){
angular.forEach(attrs, function(value, key) {
var lkey=angular.lowercase(key);
var isImage = (tag === 'img' && lkey === 'src') || (lkey === 'background');
if (validAttrs[lkey] === true &&
@@ -465,7 +465,7 @@ function htmlSanitizeWriter(buf, uriValidator){
out(unary ? '/>' : '>');
}
},
end: function(tag){
end: function(tag) {
tag = angular.lowercase(tag);
if (!ignore && validElements[tag] === true) {
out('</');
@@ -476,7 +476,7 @@ function htmlSanitizeWriter(buf, uriValidator){
ignore = false;
}
},
chars: function(chars){
chars: function(chars) {
if (!ignore) {
out(encodeEntities(chars));
}

View File

@@ -113,7 +113,7 @@ angular.scenario.Application.prototype.executeAction = function(action) {
return $injector;
};
$injector.invoke(function($browser){
$injector.invoke(function($browser) {
$browser.notifyWhenNoOutstandingRequests(function() {
action.call(self, $window, $element);
});

View File

@@ -238,7 +238,7 @@ function callerFile(offset) {
*
* To work around this we instead use our own handler that fires a real event.
*/
(function(fn){
(function(fn) {
// We need a handle to the original trigger function for input tests.
var parentTrigger = fn._originalTrigger = fn.trigger;
fn.trigger = function(type) {

View File

@@ -120,7 +120,7 @@ angular.scenario.SpecRunner.prototype.addFutureAction = function(name, behavior,
});
var result = $document.find(selector);
if (selector.match(NG)) {
angular.forEach(['[ng-','[data-ng-','[x-ng-'], function(value, index){
angular.forEach(['[ng-','[data-ng-','[x-ng-'], function(value, index) {
result = result.add(selector.replace(NG, value), $document);
});
}

View File

@@ -2,7 +2,7 @@
/* jshint -W060 */ /* we really do want to write to the document here */
(function(previousOnLoad){
(function(previousOnLoad) {
var prefix = (function() {
var filename = /(.*\/)angular-bootstrap.js(#(.*))?/;
var scripts = document.getElementsByTagName("script");

View File

@@ -304,7 +304,7 @@ angular.scenario.dsl('select', function() {
if (option.length) {
select.val(value);
} else {
option = select.find('option').filter(function(){
option = select.find('option').filter(function() {
return _jQuery(this).text() === value;
});
if (!option.length) {

View File

@@ -3,7 +3,7 @@
describe('angular', function() {
var element;
afterEach(function(){
afterEach(function() {
dealoc(element);
});
@@ -579,7 +579,7 @@ describe('angular', function() {
var args,
log = [];
(function(){ args = arguments; }('a', 'b', 'c'));
(function() { args = arguments; }('a', 'b', 'c'));
forEach(args, function(value, key) { log.push(key + ':' + value); });
expect(log).toEqual(['0:a', '1:b', '2:c']);
@@ -655,7 +655,7 @@ describe('angular', function() {
it('should follow the ES spec when called with arguments', function() {
testForEachSpec(2, (function(){ return arguments; }(1,2)));
testForEachSpec(2, (function() { return arguments; }(1,2)));
});
@@ -690,7 +690,7 @@ describe('angular', function() {
it('should follow the ES spec when called with function', function() {
function f(){}
function f() {}
f.a = 1;
f.b = 2;
testForEachSpec(2, f);
@@ -884,7 +884,7 @@ describe('angular', function() {
describe('angular service', function() {
it('should override services', function() {
module(function($provide){
module(function($provide) {
$provide.value('fake', 'old');
$provide.value('fake', 'new');
});
@@ -894,7 +894,7 @@ describe('angular', function() {
});
it('should inject dependencies specified by $inject and ignore function argument name', function() {
expect(angular.injector([function($provide){
expect(angular.injector([function($provide) {
$provide.factory('svc1', function() { return 'svc1'; });
$provide.factory('svc2', ['svc1', function(s) { return 'svc2-' + s; }]);
}]).get('svc2')).toEqual('svc2-svc1');
@@ -971,7 +971,7 @@ describe('angular', function() {
var compile = $compile(template);
var templateClone = template.clone();
element = compile($rootScope, function(clone){
element = compile($rootScope, function(clone) {
templateClone = clone;
});
$rootScope.$digest();
@@ -1039,7 +1039,7 @@ describe('angular', function() {
});
describe('bootstrap', function() {
it('should bootstrap app', function(){
it('should bootstrap app', function() {
var element = jqLite('<div>{{1+2}}</div>');
var injector = angular.bootstrap(element);
expect(injector).toBeDefined();
@@ -1135,8 +1135,8 @@ describe('angular', function() {
});
describe('startingElementHtml', function(){
it('should show starting element tag only', function(){
describe('startingElementHtml', function() {
it('should show starting element tag only', function() {
expect(startingTag('<ng-abc x="2A"><div>text</div></ng-abc>')).
toBe('<ng-abc x="2A">');
});
@@ -1149,7 +1149,7 @@ describe('angular', function() {
});
});
describe('snake_case', function(){
describe('snake_case', function() {
it('should convert to snake_case', function() {
expect(snake_case('ABC')).toEqual('a_b_c');
expect(snake_case('alanBobCharles')).toEqual('alan_bob_charles');

View File

@@ -11,7 +11,7 @@ describe('Binder', function() {
beforeEach(function() {
this.compileToHtml = function (content) {
var html;
inject(function($rootScope, $compile){
inject(function($rootScope, $compile) {
content = jqLite(content);
$compile(content)($rootScope);
html = sortedHtml(content);
@@ -168,7 +168,7 @@ describe('Binder', function() {
}));
it('IfAttrBindingThrowsErrorDecorateTheAttribute', function() {
module(function($exceptionHandlerProvider){
module(function($exceptionHandlerProvider) {
$exceptionHandlerProvider.mode('log');
});
inject(function($rootScope, $exceptionHandler, $compile) {
@@ -344,7 +344,7 @@ describe('Binder', function() {
}));
it('ActionOnAHrefThrowsError', function() {
module(function($exceptionHandlerProvider){
module(function($exceptionHandlerProvider) {
$exceptionHandlerProvider.mode('log');
});
inject(function($rootScope, $exceptionHandler, $compile) {

View File

@@ -11,7 +11,7 @@ describe('injector', function() {
};
providerInjector = $injector;
}));
beforeEach(inject(function($injector){
beforeEach(inject(function($injector) {
injector = $injector;
}));
@@ -295,9 +295,9 @@ describe('injector', function() {
it('should load dependant modules only once', function() {
var log = '';
angular.module('a', [], function(){ log += 'a'; });
angular.module('b', ['a'], function(){ log += 'b'; });
angular.module('c', ['a', 'b'], function(){ log += 'c'; });
angular.module('a', [], function() { log += 'a'; });
angular.module('b', ['a'], function() { log += 'b'; });
angular.module('c', ['a', 'b'], function() { log += 'c'; });
createInjector(['c', 'c']);
expect(log).toEqual('abc');
});
@@ -327,8 +327,8 @@ describe('injector', function() {
it('should execute runBlocks after injector creation', function() {
var log = '';
angular.module('a', [], function(){ log += 'a'; }).run(function() { log += 'A'; });
angular.module('b', ['a'], function(){ log += 'b'; }).run(function() { log += 'B'; });
angular.module('a', [], function() { log += 'a'; }).run(function() { log += 'A'; });
angular.module('b', ['a'], function() { log += 'b'; }).run(function() { log += 'B'; });
createInjector([
'b',
valueFn(function() { log += 'C'; }),
@@ -383,7 +383,7 @@ describe('injector', function() {
it('should create configuration injectable constants', function() {
var log = [];
createInjector([
function($provide){
function($provide) {
$provide.constant('abc', 123);
$provide.constant({a: 'A', b:'B'});
return function(a) {
@@ -660,7 +660,7 @@ describe('injector', function() {
it('should decorate the missing service error with module function', function() {
function myModule(xyzzy){}
function myModule(xyzzy) {}
expect(function() {
createInjector([myModule]);
}).toThrowMinErr(
@@ -670,7 +670,7 @@ describe('injector', function() {
it('should decorate the missing service error with module array function', function() {
function myModule(xyzzy){}
function myModule(xyzzy) {}
expect(function() {
createInjector([['xyzzy', myModule]]);
}).toThrowMinErr(
@@ -681,8 +681,8 @@ describe('injector', function() {
it('should throw error when trying to inject oneself', function() {
expect(function() {
createInjector([function($provide){
$provide.factory('service', function(service){});
createInjector([function($provide) {
$provide.factory('service', function(service) {});
return function(service) {};
}]);
}).toThrowMinErr('$injector', 'cdep', 'Circular dependency found: service <- service');
@@ -691,9 +691,9 @@ describe('injector', function() {
it('should throw error when trying to inject circular dependency', function() {
expect(function() {
createInjector([function($provide){
$provide.factory('a', function(b){});
$provide.factory('b', function(a){});
createInjector([function($provide) {
$provide.factory('a', function(b) {});
$provide.factory('b', function(a) {});
return function(a) {};
}]);
}).toThrowMinErr('$injector', 'cdep', 'Circular dependency found: a <- b <- a');

View File

@@ -8,11 +8,11 @@ beforeEach(function() {
var present = true;
var absent = false;
angular.forEach(presentClasses.split(' '), function(className){
angular.forEach(presentClasses.split(' '), function(className) {
present = present && element.hasClass(className);
});
angular.forEach(absentClasses.split(' '), function(className){
angular.forEach(absentClasses.split(' '), function(className) {
absent = absent || element.hasClass(className);
});

View File

@@ -152,7 +152,7 @@ function sortedHtml(element, showNgClass) {
if (node.nodeName == "#text") {
html += node.nodeValue.
replace(/&(\w+[&;\W])?/g, function(match, entity){return entity?match:'&amp;';}).
replace(/&(\w+[&;\W])?/g, function(match, entity) {return entity?match:'&amp;';}).
replace(/</g, '&lt;').
replace(/>/g, '&gt;');
} else if (node.nodeName == "#comment") {
@@ -211,7 +211,7 @@ function sortedHtml(element, showNgClass) {
if (node.style) {
var style = [];
if (node.style.cssText) {
forEach(node.style.cssText.split(';'), function(value){
forEach(node.style.cssText.split(';'), function(value) {
value = trim(value);
if (value) {
style.push(lowercase(value));
@@ -230,7 +230,7 @@ function sortedHtml(element, showNgClass) {
style.sort();
var tmp = style;
style = [];
forEach(tmp, function(value){
forEach(tmp, function(value) {
if (!value.match(/^max[^\-]/))
style.push(value);
});

View File

@@ -999,7 +999,7 @@ describe('jqLite', function() {
alert: noop,
setInterval: noop,
length:10, // pretend you are an array
addEventListener: function(type, fn){
addEventListener: function(type, fn) {
expect(type).toEqual('hashchange');
eventFn = fn;
},
@@ -1158,8 +1158,8 @@ describe('jqLite', function() {
it('should fire mouseenter when coming from outside the browser window', function() {
if (window.jQuery) return;
var browserMoveTrigger = function(from, to){
var fireEvent = function(type, element, relatedTarget){
var browserMoveTrigger = function(from, to) {
var fireEvent = function(type, element, relatedTarget) {
var evnt;
evnt = document.createEvent('MouseEvents');

View File

@@ -95,7 +95,7 @@ function MockDocument() {
this.find = function(name) {
if (name == 'base') {
return {
attr: function(name){
attr: function(name) {
if (name == 'href') {
return self.basePath;
} else {

View File

@@ -28,7 +28,7 @@ describe('$compile', function() {
var element, directive, $compile, $rootScope;
beforeEach(module(provideLog, function($provide, $compileProvider){
beforeEach(module(provideLog, function($provide, $compileProvider) {
element = null;
directive = $compileProvider.directive;
@@ -101,7 +101,7 @@ describe('$compile', function() {
};
});
directive('svgCircle', function(){
directive('svgCircle', function() {
return {
template: '<circle cx="2" cy="2" r="1"></circle>',
templateNamespace: 'svg',
@@ -109,7 +109,7 @@ describe('$compile', function() {
};
});
directive('myForeignObject', function(){
directive('myForeignObject', function() {
return {
template: '<foreignObject width="100" height="100" ng-transclude></foreignObject>',
templateNamespace: 'svg',
@@ -130,7 +130,7 @@ describe('$compile', function() {
$compile(element)($rootScope);
}
afterEach(function(){
afterEach(function() {
dealoc(element);
});
@@ -202,7 +202,7 @@ describe('$compile', function() {
expect(box.width === 0 && box.height === 0).toBe(false);
}
it('should handle transcluded svg elements', inject(function($compile){
it('should handle transcluded svg elements', inject(function($compile) {
element = jqLite('<div><svg-container>' +
'<circle cx="4" cy="4" r="2"></circle>' +
'</svg-container></div>');
@@ -214,7 +214,7 @@ describe('$compile', function() {
assertIsValidSvgCircle(circle[0]);
}));
it('should handle custom svg elements inside svg tag', inject(function(){
it('should handle custom svg elements inside svg tag', inject(function() {
element = jqLite('<div><svg width="300" height="300">' +
'<svg-circle></svg-circle>' +
'</svg></div>');
@@ -225,7 +225,7 @@ describe('$compile', function() {
assertIsValidSvgCircle(circle[0]);
}));
it('should handle transcluded custom svg elements', inject(function(){
it('should handle transcluded custom svg elements', inject(function() {
element = jqLite('<div><svg-container>' +
'<svg-circle></svg-circle>' +
'</svg-container></div>');
@@ -237,7 +237,7 @@ describe('$compile', function() {
}));
if (supportsForeignObject()) {
it('should handle foreignObject', inject(function(){
it('should handle foreignObject', inject(function() {
element = jqLite('<div><svg-container>' +
'<foreignObject width="100" height="100"><div class="test" style="position:absolute;width:20px;height:20px">test</div></foreignObject>' +
'</svg-container></div>');
@@ -250,7 +250,7 @@ describe('$compile', function() {
expect(bounds.width === 20 && bounds.height === 20).toBe(true);
}));
it('should handle custom svg containers that transclude to foreignObject that transclude html', inject(function(){
it('should handle custom svg containers that transclude to foreignObject that transclude html', inject(function() {
element = jqLite('<div><svg-container>' +
'<my-foreign-object><div class="test" style="width:20px;height:20px">test</div></my-foreign-object>' +
'</svg-container></div>');
@@ -265,7 +265,7 @@ describe('$compile', function() {
// NOTE: This test may be redundant.
it('should handle custom svg containers that transclude to foreignObject'+
' that transclude to custom svg containers that transclude to custom elements', inject(function(){
' that transclude to custom svg containers that transclude to custom elements', inject(function() {
element = jqLite('<div><svg-container>' +
'<my-foreign-object><svg-container><svg-circle></svg-circle></svg-container></my-foreign-object>' +
'</svg-container></div>');
@@ -327,7 +327,7 @@ describe('$compile', function() {
describe('compile phase', function() {
it('should attach scope to the document node when it is compiled explicitly', inject(function($document){
it('should attach scope to the document node when it is compiled explicitly', inject(function($document) {
$compile($document)($rootScope);
expect($document.scope()).toBe($rootScope);
}));
@@ -410,7 +410,7 @@ describe('$compile', function() {
describe('multiple directives per element', function() {
it('should allow multiple directives per element', inject(function($compile, $rootScope, log){
it('should allow multiple directives per element', inject(function($compile, $rootScope, log) {
element = $compile(
'<span greet="angular" log="L" x-high-log="H" data-medium-log="M"></span>')
($rootScope);
@@ -419,7 +419,7 @@ describe('$compile', function() {
}));
it('should recurse to children', inject(function($compile, $rootScope){
it('should recurse to children', inject(function($compile, $rootScope) {
element = $compile('<div>0<a set="hello">1</a>2<b set="angular">3</b>4</div>')($rootScope);
expect(element.text()).toEqual('0hello2angular4');
}));
@@ -511,7 +511,7 @@ describe('$compile', function() {
elementName = parts.shift();
parts.sort();
parts.unshift(elementName);
forEach(parts, function(value){
forEach(parts, function(value) {
if (value.substring(0,2) !== 'ng') {
value = value.replace('=""', '');
var match = value.match(/=(.*)/);
@@ -528,14 +528,14 @@ describe('$compile', function() {
it('should allow changing the template structure after the current node', function() {
module(function(){
module(function() {
directive('after', valueFn({
compile: function(element) {
element.after('<span log>B</span>');
}
}));
});
inject(function($compile, $rootScope, log){
inject(function($compile, $rootScope, log) {
element = jqLite("<div><div after>A</div></div>");
$compile(element)($rootScope);
expect(element.text()).toBe('AB');
@@ -545,14 +545,14 @@ describe('$compile', function() {
it('should allow changing the template structure after the current node inside ngRepeat', function() {
module(function(){
module(function() {
directive('after', valueFn({
compile: function(element) {
element.after('<span log>B</span>');
}
}));
});
inject(function($compile, $rootScope, log){
inject(function($compile, $rootScope, log) {
element = jqLite('<div><div ng-repeat="i in [1,2]"><div after>A</div></div></div>');
$compile(element)($rootScope);
$rootScope.$digest();
@@ -583,7 +583,7 @@ describe('$compile', function() {
describe('compiler control', function() {
describe('priority', function() {
it('should honor priority', inject(function($compile, $rootScope, log){
it('should honor priority', inject(function($compile, $rootScope, log) {
element = $compile(
'<span log="L" x-high-log="H" data-medium-log="M"></span>')
($rootScope);
@@ -1571,7 +1571,7 @@ describe('$compile', function() {
templateUrl: 'template.html'
}));
});
inject(function($compile, $httpBackend){
inject(function($compile, $httpBackend) {
$httpBackend.whenGET('template.html').respond('<p>template.html</p>');
expect(function() {
$compile('<div><div class="sync async"></div></div>');
@@ -1602,7 +1602,7 @@ describe('$compile', function() {
});
describe('delay compile / linking functions until after template is resolved', function(){
describe('delay compile / linking functions until after template is resolved', function() {
var template;
beforeEach(module(function() {
function logDirective(name, priority, options) {
@@ -2255,7 +2255,7 @@ describe('$compile', function() {
it('should not allow more then one isolate scope creation per element', inject(
function($rootScope, $compile) {
expect(function(){
expect(function() {
$compile('<div class="iscope-a; scope-b"></div>');
}).toThrowMinErr('$compile', 'multidir', 'Multiple directives [iscopeA, scopeB] asking for new/isolated scope on: ' +
'<div class="iscope-a; scope-b">');
@@ -2274,7 +2274,7 @@ describe('$compile', function() {
});
});
inject(function($compile) {
expect(function(){
expect(function() {
$compile('<div class="iscope-a; high-priority-scope"></div>');
}).toThrowMinErr('$compile', 'multidir', 'Multiple directives [highPriorityScope, iscopeA] asking for new/isolated scope on: ' +
'<div class="iscope-a; high-priority-scope">');
@@ -2992,7 +2992,7 @@ describe('$compile', function() {
describe('$set', function() {
var attr;
beforeEach(function(){
beforeEach(function() {
module(function() {
directive('input', valueFn({
restrict: 'ECA',
@@ -3698,7 +3698,7 @@ describe('$compile', function() {
});
it('should update @-bindings on controller when bindToController and attribute change observed', function(){
it('should update @-bindings on controller when bindToController and attribute change observed', function() {
module(function($compileProvider) {
$compileProvider.directive('atBinding', valueFn({
template: '<p>{{At.text}}</p>',

View File

@@ -10,7 +10,7 @@ describe('a', function() {
}));
afterEach(function(){
afterEach(function() {
dealoc(element);
});

View File

@@ -2366,21 +2366,21 @@ describe('input', function() {
// INPUT TYPES
describe('month', function (){
describe('month', function () {
it('should throw if model is not a Date object', function() {
compileInput('<input type="month" ng-model="january"/>');
expect(function() {
scope.$apply(function(){
scope.$apply(function() {
scope.january = '2013-01';
});
}).toThrowMinErr('ngModel', 'datefmt', 'Expected `2013-01` to be a date');
});
it('should set the view if the model is a valid Date object', function (){
it('should set the view if the model is a valid Date object', function () {
compileInput('<input type="month" ng-model="march"/>');
scope.$apply(function(){
scope.$apply(function() {
scope.march = new Date(2013, 2, 1);
});
@@ -2390,7 +2390,7 @@ describe('input', function() {
it('should set the model undefined if the input is an invalid month string', function () {
compileInput('<input type="month" ng-model="value"/>');
scope.$apply(function(){
scope.$apply(function() {
scope.value = new Date(2013, 0, 1);
});
@@ -2477,29 +2477,29 @@ describe('input', function() {
expect(inputElm.val()).toBe('2013-12');
});
describe('min', function (){
describe('min', function () {
var scope;
beforeEach(inject(function ($rootScope){
beforeEach(inject(function ($rootScope) {
scope = $rootScope;
$rootScope.minVal = '2013-01';
compileInput('<input type="month" ng-model="value" name="alias" min="{{ minVal }}" />');
}));
it('should invalidate', function (){
it('should invalidate', function () {
changeInputValueTo('2012-12');
expect(inputElm).toBeInvalid();
expect(scope.value).toBeFalsy();
expect(scope.form.alias.$error.min).toBeTruthy();
});
it('should validate', function (){
it('should validate', function () {
changeInputValueTo('2013-07');
expect(inputElm).toBeValid();
expect(+scope.value).toBe(+new Date(2013, 6, 1));
expect(scope.form.alias.$error.min).toBeFalsy();
});
it('should revalidate when the min value changes', function (){
it('should revalidate when the min value changes', function () {
changeInputValueTo('2013-07');
expect(inputElm).toBeValid();
expect(scope.form.alias.$error.min).toBeFalsy();
@@ -2512,29 +2512,29 @@ describe('input', function() {
});
});
describe('max', function(){
describe('max', function() {
var scope;
beforeEach(inject(function ($rootScope){
beforeEach(inject(function ($rootScope) {
scope = $rootScope;
$rootScope.maxVal = '2013-01';
compileInput('<input type="month" ng-model="value" name="alias" max="{{ maxVal }}" />');
}));
it('should validate', function (){
it('should validate', function () {
changeInputValueTo('2012-03');
expect(inputElm).toBeValid();
expect(+scope.value).toBe(+new Date(2012, 2, 1));
expect(scope.form.alias.$error.max).toBeFalsy();
});
it('should invalidate', function (){
it('should invalidate', function () {
changeInputValueTo('2013-05');
expect(inputElm).toBeInvalid();
expect(scope.value).toBeUndefined();
expect(scope.form.alias.$error.max).toBeTruthy();
});
it('should revalidate when the max value changes', function (){
it('should revalidate when the max value changes', function () {
changeInputValueTo('2012-07');
expect(inputElm).toBeValid();
expect(scope.form.alias.$error.max).toBeFalsy();
@@ -2548,31 +2548,31 @@ describe('input', function() {
});
});
describe('week', function (){
describe('week', function () {
it('should throw if model is not a Date object', function() {
compileInput('<input type="week" ng-model="secondWeek"/>');
expect(function() {
scope.$apply(function(){
scope.$apply(function() {
scope.secondWeek = '2013-W02';
});
}).toThrowMinErr('ngModel', 'datefmt', 'Expected `2013-W02` to be a date');
});
it('should set the view if the model is a valid Date object', function (){
it('should set the view if the model is a valid Date object', function () {
compileInput('<input type="week" ng-model="secondWeek"/>');
scope.$apply(function(){
scope.$apply(function() {
scope.secondWeek = new Date(2013, 0, 11);
});
expect(inputElm.val()).toBe('2013-W02');
});
it('should not affect the hours or minutes of a bound date', function (){
it('should not affect the hours or minutes of a bound date', function () {
compileInput('<input type="week" ng-model="secondWeek"/>');
scope.$apply(function(){
scope.$apply(function() {
scope.secondWeek = new Date(2013, 0, 11, 1, 0, 0, 0);
});
@@ -2584,7 +2584,7 @@ describe('input', function() {
it('should set the model undefined if the input is an invalid week string', function () {
compileInput('<input type="week" ng-model="value"/>');
scope.$apply(function(){
scope.$apply(function() {
scope.value = new Date(2013, 0, 11);
});
@@ -2660,29 +2660,29 @@ describe('input', function() {
expect(scope.form.alias.$error.week).toBeTruthy();
});
describe('min', function (){
describe('min', function () {
var scope;
beforeEach(inject(function ($rootScope){
beforeEach(inject(function ($rootScope) {
scope = $rootScope;
$rootScope.minVal = '2013-W01';
compileInput('<input type="week" ng-model="value" name="alias" min="{{ minVal }}" />');
}));
it('should invalidate', function (){
it('should invalidate', function () {
changeInputValueTo('2012-W12');
expect(inputElm).toBeInvalid();
expect(scope.value).toBeFalsy();
expect(scope.form.alias.$error.min).toBeTruthy();
});
it('should validate', function (){
it('should validate', function () {
changeInputValueTo('2013-W03');
expect(inputElm).toBeValid();
expect(+scope.value).toBe(+new Date(2013, 0, 17));
expect(scope.form.alias.$error.min).toBeFalsy();
});
it('should revalidate when the min value changes', function (){
it('should revalidate when the min value changes', function () {
changeInputValueTo('2013-W03');
expect(inputElm).toBeValid();
expect(scope.form.alias.$error.min).toBeFalsy();
@@ -2695,28 +2695,28 @@ describe('input', function() {
});
});
describe('max', function(){
beforeEach(inject(function ($rootScope){
describe('max', function() {
beforeEach(inject(function ($rootScope) {
$rootScope.maxVal = '2013-W01';
scope = $rootScope;
compileInput('<input type="week" ng-model="value" name="alias" max="{{ maxVal }}" />');
}));
it('should validate', function (){
it('should validate', function () {
changeInputValueTo('2012-W01');
expect(inputElm).toBeValid();
expect(+scope.value).toBe(+new Date(2012, 0, 5));
expect(scope.form.alias.$error.max).toBeFalsy();
});
it('should invalidate', function (){
it('should invalidate', function () {
changeInputValueTo('2013-W03');
expect(inputElm).toBeInvalid();
expect(scope.value).toBeUndefined();
expect(scope.form.alias.$error.max).toBeTruthy();
});
it('should revalidate when the max value changes', function (){
it('should revalidate when the max value changes', function () {
changeInputValueTo('2012-W03');
expect(inputElm).toBeValid();
expect(scope.form.alias.$error.max).toBeFalsy();
@@ -2735,26 +2735,26 @@ describe('input', function() {
compileInput('<input type="datetime-local" ng-model="lunchtime"/>');
expect(function() {
scope.$apply(function(){
scope.$apply(function() {
scope.lunchtime = '2013-12-16T11:30:00';
});
}).toThrowMinErr('ngModel', 'datefmt', 'Expected `2013-12-16T11:30:00` to be a date');
});
it('should set the view if the model if a valid Date object.', function(){
it('should set the view if the model if a valid Date object.', function() {
compileInput('<input type="datetime-local" ng-model="halfSecondToNextYear"/>');
scope.$apply(function (){
scope.$apply(function () {
scope.halfSecondToNextYear = new Date(2013, 11, 31, 23, 59, 59, 500);
});
expect(inputElm.val()).toBe('2013-12-31T23:59:59.500');
});
it('should set the model undefined if the view is invalid', function (){
it('should set the model undefined if the view is invalid', function () {
compileInput('<input type="datetime-local" ng-model="breakMe"/>');
scope.$apply(function (){
scope.$apply(function () {
scope.breakMe = new Date(2009, 0, 6, 16, 25, 0);
});
@@ -2862,29 +2862,29 @@ describe('input', function() {
expect(scope.form.alias.$error.datetimelocal).toBeTruthy();
});
describe('min', function (){
describe('min', function () {
var scope;
beforeEach(inject(function ($rootScope){
beforeEach(inject(function ($rootScope) {
$rootScope.minVal = '2000-01-01T12:30:00';
scope = $rootScope;
compileInput('<input type="datetime-local" ng-model="value" name="alias" min="{{ minVal }}" />');
}));
it('should invalidate', function (){
it('should invalidate', function () {
changeInputValueTo('1999-12-31T01:02:00');
expect(inputElm).toBeInvalid();
expect(scope.value).toBeFalsy();
expect(scope.form.alias.$error.min).toBeTruthy();
});
it('should validate', function (){
it('should validate', function () {
changeInputValueTo('2000-01-01T23:02:00');
expect(inputElm).toBeValid();
expect(+scope.value).toBe(+new Date(2000, 0, 1, 23, 2, 0));
expect(scope.form.alias.$error.min).toBeFalsy();
});
it('should revalidate when the min value changes', function (){
it('should revalidate when the min value changes', function () {
changeInputValueTo('2000-02-01T01:02:00');
expect(inputElm).toBeValid();
expect(scope.form.alias.$error.min).toBeFalsy();
@@ -2897,15 +2897,15 @@ describe('input', function() {
});
});
describe('max', function (){
describe('max', function () {
var scope;
beforeEach(inject(function ($rootScope){
beforeEach(inject(function ($rootScope) {
$rootScope.maxVal = '2019-01-01T01:02:00';
scope = $rootScope;
compileInput('<input type="datetime-local" ng-model="value" name="alias" max="{{ maxVal }}" />');
}));
it('should invalidate', function (){
it('should invalidate', function () {
changeInputValueTo('2019-12-31T01:02:00');
expect(inputElm).toBeInvalid();
expect(scope.value).toBeFalsy();
@@ -2919,7 +2919,7 @@ describe('input', function() {
expect(scope.form.alias.$error.max).toBeFalsy();
});
it('should revalidate when the max value changes', function (){
it('should revalidate when the max value changes', function () {
changeInputValueTo('2000-02-01T01:02:00');
expect(inputElm).toBeValid();
expect(scope.form.alias.$error.max).toBeFalsy();
@@ -3010,26 +3010,26 @@ describe('input', function() {
compileInput('<input type="time" ng-model="lunchtime"/>');
expect(function() {
scope.$apply(function(){
scope.$apply(function() {
scope.lunchtime = '11:30:00';
});
}).toThrowMinErr('ngModel', 'datefmt', 'Expected `11:30:00` to be a date');
});
it('should set the view if the model if a valid Date object.', function(){
it('should set the view if the model if a valid Date object.', function() {
compileInput('<input type="time" ng-model="threeFortyOnePm"/>');
scope.$apply(function (){
scope.$apply(function () {
scope.threeFortyOnePm = new Date(1970, 0, 1, 15, 41, 0, 500);
});
expect(inputElm.val()).toBe('15:41:00.500');
});
it('should set the model undefined if the view is invalid', function (){
it('should set the model undefined if the view is invalid', function () {
compileInput('<input type="time" ng-model="breakMe"/>');
scope.$apply(function (){
scope.$apply(function () {
scope.breakMe = new Date(1970, 0, 1, 16, 25, 0);
});
@@ -3140,7 +3140,7 @@ describe('input', function() {
it('should only change hours and minute of a bound date', function() {
compileInput('<input type="time" ng-model="value"" />');
scope.$apply(function(){
scope.$apply(function() {
scope.value = new Date(2013, 2, 3, 1, 0, 0);
});
@@ -3148,29 +3148,29 @@ describe('input', function() {
expect(+scope.value).toBe(+new Date(2013, 2, 3, 1, 2, 0));
});
describe('min', function (){
describe('min', function () {
var scope;
beforeEach(inject(function ($rootScope){
beforeEach(inject(function ($rootScope) {
$rootScope.minVal = '09:30:00';
scope = $rootScope;
compileInput('<input type="time" ng-model="value" name="alias" min="{{ minVal }}" />');
}));
it('should invalidate', function (){
it('should invalidate', function () {
changeInputValueTo('01:02:00');
expect(inputElm).toBeInvalid();
expect(scope.value).toBeFalsy();
expect(scope.form.alias.$error.min).toBeTruthy();
});
it('should validate', function (){
it('should validate', function () {
changeInputValueTo('23:02:00');
expect(inputElm).toBeValid();
expect(+scope.value).toBe(+new Date(1970, 0, 1, 23, 2, 0));
expect(scope.form.alias.$error.min).toBeFalsy();
});
it('should revalidate when the min value changes', function (){
it('should revalidate when the min value changes', function () {
changeInputValueTo('23:02:00');
expect(inputElm).toBeValid();
expect(scope.form.alias.$error.min).toBeFalsy();
@@ -3183,12 +3183,12 @@ describe('input', function() {
});
});
describe('max', function (){
beforeEach(function (){
describe('max', function () {
beforeEach(function () {
compileInput('<input type="time" ng-model="value" name="alias" max="22:30:00" />');
});
it('should invalidate', function (){
it('should invalidate', function () {
changeInputValueTo('23:00:00');
expect(inputElm).toBeInvalid();
expect(scope.value).toBeFalsy();
@@ -3261,7 +3261,7 @@ describe('input', function() {
compileInput('<input type="date" ng-model="birthday"/>');
expect(function() {
scope.$apply(function(){
scope.$apply(function() {
scope.birthday = '1977-10-22';
});
}).toThrowMinErr('ngModel', 'datefmt', 'Expected `1977-10-22` to be a date');
@@ -3273,27 +3273,27 @@ describe('input', function() {
// would always set the input.value to empty for invalid dates...
inputElm.attr('type', 'text');
scope.$apply(function (){
scope.$apply(function () {
scope.val = new Date('a');
});
expect(inputElm.val()).toBe('');
});
it('should set the view if the model if a valid Date object.', function(){
it('should set the view if the model if a valid Date object.', function() {
compileInput('<input type="date" ng-model="christmas"/>');
scope.$apply(function (){
scope.$apply(function () {
scope.christmas = new Date(2013, 11, 25);
});
expect(inputElm.val()).toBe('2013-12-25');
});
it('should set the model undefined if the view is invalid', function (){
it('should set the model undefined if the view is invalid', function () {
compileInput('<input type="date" ng-model="arrMatey"/>');
scope.$apply(function (){
scope.$apply(function () {
scope.arrMatey = new Date(2014, 8, 14);
});
@@ -3412,19 +3412,19 @@ describe('input', function() {
}
});
describe('min', function (){
beforeEach(function (){
describe('min', function () {
beforeEach(function () {
compileInput('<input type="date" ng-model="value" name="alias" min="2000-01-01" />');
});
it('should invalidate', function (){
it('should invalidate', function () {
changeInputValueTo('1999-12-31');
expect(inputElm).toBeInvalid();
expect(scope.value).toBeFalsy();
expect(scope.form.alias.$error.min).toBeTruthy();
});
it('should validate', function (){
it('should validate', function () {
changeInputValueTo('2000-01-01');
expect(inputElm).toBeValid();
expect(+scope.value).toBe(+new Date(2000, 0, 1));
@@ -3449,12 +3449,12 @@ describe('input', function() {
}));
});
describe('max', function (){
beforeEach(function (){
describe('max', function () {
beforeEach(function () {
compileInput('<input type="date" ng-model="value" name="alias" max="2019-01-01" />');
});
it('should invalidate', function (){
it('should invalidate', function () {
changeInputValueTo('2019-12-31');
expect(inputElm).toBeInvalid();
expect(scope.value).toBeFalsy();

View File

@@ -255,7 +255,7 @@ describe('ngIf animations', function () {
};
}));
afterEach(function(){
afterEach(function() {
dealoc(body);
dealoc(element);
});

View File

@@ -3,7 +3,7 @@
describe('ngInclude', function() {
var element;
afterEach(function(){
afterEach(function() {
dealoc(element);
});
@@ -650,14 +650,14 @@ describe('ngInclude animations', function() {
};
}));
afterEach(function(){
afterEach(function() {
dealoc(body);
dealoc(element);
});
beforeEach(module('ngAnimateMock'));
afterEach(function(){
afterEach(function() {
dealoc(element);
});

View File

@@ -5,7 +5,7 @@ describe('ngNonBindable', function() {
var element;
afterEach(function(){
afterEach(function() {
dealoc(element);
});

View File

@@ -5,7 +5,7 @@ describe('ngPluralize', function() {
elementAlt;
afterEach(function(){
afterEach(function() {
dealoc(element);
dealoc(elementAlt);
});

View File

@@ -1379,7 +1379,7 @@ describe('ngRepeat animations', function() {
};
}));
afterEach(function(){
afterEach(function() {
body.empty();
});

View File

@@ -45,7 +45,7 @@ describe('ngShow / ngHide', function() {
it('should show if the expression is a function with a no arguments', function() {
element = jqLite('<div ng-show="exp"></div>');
element = $compile(element)($scope);
$scope.exp = function(){};
$scope.exp = function() {};
$scope.$digest();
expect(element).toBeShown();
});
@@ -119,7 +119,7 @@ describe('ngShow / ngHide animations', function() {
body = jqLite(document.body);
});
afterEach(function(){
afterEach(function() {
dealoc(body);
dealoc(element);
body.removeAttr('ng-animation-running');

View File

@@ -4,7 +4,7 @@ describe('ngSwitch', function() {
var element;
afterEach(function(){
afterEach(function() {
dealoc(element);
});
@@ -319,7 +319,7 @@ describe('ngSwitch animation', function() {
};
}));
afterEach(function(){
afterEach(function() {
dealoc(body);
dealoc(element);
});

View File

@@ -4,7 +4,7 @@ describe('scriptDirective', function() {
var element;
afterEach(function(){
afterEach(function() {
dealoc(element);
});

View File

@@ -25,7 +25,7 @@ describe('select', function() {
beforeEach(function() {
this.addMatchers({
toEqualSelect: function(expected){
toEqualSelect: function(expected) {
var actualValues = [],
expectedValues = [].slice.call(arguments);

View File

@@ -3,7 +3,7 @@
describe('$exceptionHandler', function() {
/* global $ExceptionHandlerProvider:false */
it('should log errors with single argument', function() {
module(function($provide){
module(function($provide) {
$provide.provider('$exceptionHandler', $ExceptionHandlerProvider);
});
inject(function($log, $exceptionHandler) {
@@ -14,7 +14,7 @@ describe('$exceptionHandler', function() {
it('should log errors with multiple arguments', function() {
module(function($provide){
module(function($provide) {
$provide.provider('$exceptionHandler', $ExceptionHandlerProvider);
});
inject(function($log, $exceptionHandler) {

View File

@@ -3,7 +3,7 @@
describe('Filter: filter', function() {
var filter;
beforeEach(inject(function($filter){
beforeEach(inject(function($filter) {
filter = $filter('filter');
}));

View File

@@ -4,11 +4,11 @@ describe('filters', function() {
var filter;
beforeEach(inject(function($filter){
beforeEach(inject(function($filter) {
filter = $filter;
}));
it('should call the filter when evaluating expression', function(){
it('should call the filter when evaluating expression', function() {
var filter = jasmine.createSpy('myFilter');
createInjector(['ng', function($filterProvider) {
$filterProvider.register('myFilter', valueFn(filter));
@@ -73,7 +73,7 @@ describe('filters', function() {
expect(num).toBe('123.112');
});
it('should format the same with string as well as numeric fractionSize', function(){
it('should format the same with string as well as numeric fractionSize', function() {
var num = formatNumber(123.1, pattern, ',', '.', "0");
expect(num).toBe('123');
num = formatNumber(123.1, pattern, ',', '.', 0);
@@ -84,7 +84,7 @@ describe('filters', function() {
expect(num).toBe('123.100');
});
it('should format numbers that round to zero as nonnegative', function(){
it('should format numbers that round to zero as nonnegative', function() {
var num = formatNumber(-0.01, pattern, ',', '.', 1);
expect(num).toBe('0.0');
});

View File

@@ -26,8 +26,8 @@ describe('Filter: orderBy', function() {
expect(orderBy([{a:15}, {a:2}], 'a', "reverse")).toEqualData([{a:15}, {a:2}]);
});
it('should sort inherited from array', function(){
function BaseCollection(){}
it('should sort inherited from array', function() {
function BaseCollection() {}
BaseCollection.prototype = Array.prototype;
var child = new BaseCollection();
child.push({a:2});

View File

@@ -863,7 +863,7 @@ describe('$http', function() {
$http.put('/url', 'some-data', {headers: {'Custom': 'Header'}});
});
it('should have patch()', function(){
it('should have patch()', function() {
$httpBackend.expect('PATCH', '/url', 'some-data').respond('');
$http.patch('/url', 'some-data');
});
@@ -904,7 +904,7 @@ describe('$http', function() {
});
it('should $apply even if exception thrown during callback', inject(function($exceptionHandler){
it('should $apply even if exception thrown during callback', inject(function($exceptionHandler) {
$httpBackend.when('GET').respond(200);
callback.andThrow('error in callback');
@@ -1111,7 +1111,7 @@ describe('$http', function() {
});
it('should not attempt to deserialize json when HEAD request', function(){
it('should not attempt to deserialize json when HEAD request', function() {
//per http spec for Content-Type, HEAD request should return a Content-Type header
//set to what the content type would have been if a get was sent
$httpBackend.expect('HEAD', '/url').respond('', {'Content-Type': 'application/json'});
@@ -1122,7 +1122,7 @@ describe('$http', function() {
expect(callback.mostRecentCall.args[0]).toEqual('');
});
it('should not attempt to deserialize json for an empty response whose header contains application/json', function(){
it('should not attempt to deserialize json for an empty response whose header contains application/json', function() {
//per http spec for Content-Type, HEAD request should return a Content-Type header
//set to what the content type would have been if a get was sent
$httpBackend.expect('GET', '/url').respond('', {'Content-Type': 'application/json'});

View File

@@ -3,7 +3,7 @@
describe('$interval', function() {
/* global $IntervalProvider: false */
beforeEach(module(function($provide){
beforeEach(module(function($provide) {
var repeatFns = [],
nextRepeatId = 0,
now = 0,
@@ -17,7 +17,7 @@ describe('$interval', function() {
fn: fn,
id: nextRepeatId
});
repeatFns.sort(function(a, b){ return a.nextTime - b.nextTime;});
repeatFns.sort(function(a, b) { return a.nextTime - b.nextTime;});
return nextRepeatId++;
},
@@ -43,7 +43,7 @@ describe('$interval', function() {
var task = repeatFns[0];
task.fn();
task.nextTime += task.delay;
repeatFns.sort(function(a, b){ return a.nextTime - b.nextTime;});
repeatFns.sort(function(a, b) { return a.nextTime - b.nextTime;});
}
return millis;
}

View File

@@ -44,7 +44,7 @@ describe('$location', function() {
}));
it('should not include the drive name in path() on WIN', function (){
it('should not include the drive name in path() on WIN', function () {
//See issue #4680 for details
url = new LocationHashbangUrl('file:///base', '#!');
url.$$parse('file:///base#!/foo?a=b&c#hash');
@@ -626,14 +626,14 @@ describe('$location', function() {
function initService(options) {
return module(function($provide, $locationProvider){
return module(function($provide, $locationProvider) {
$locationProvider.html5Mode(options.html5Mode);
$locationProvider.hashPrefix(options.hashPrefix);
$provide.value('$sniffer', {history: options.supportHistory});
});
}
function initBrowser(options) {
return function($browser){
return function($browser) {
$browser.url(options.url);
$browser.$$baseHref = options.basePath;
};
@@ -915,7 +915,7 @@ describe('$location', function() {
// html5 history enabled, but not supported by browser
describe('history on old browser', function() {
afterEach(inject(function($rootElement){
afterEach(inject(function($rootElement) {
dealoc($rootElement);
}));
@@ -959,7 +959,7 @@ describe('$location', function() {
// html5 history enabled and supported by browser
describe('history on new browser', function() {
afterEach(inject(function($rootElement){
afterEach(inject(function($rootElement) {
dealoc($rootElement);
}));
@@ -1081,7 +1081,7 @@ describe('$location', function() {
}
function initBrowser() {
return function($browser, $document){
return function($browser, $document) {
$browser.url('http://host.com/base/index.html');
$browser.$$baseHref = '/base/index.html';
};
@@ -1826,7 +1826,7 @@ describe('$location', function() {
});
});
inject(function(){});
inject(function() {});
});
@@ -1845,7 +1845,7 @@ describe('$location', function() {
});
});
inject(function(){});
inject(function() {});
});
@@ -1862,7 +1862,7 @@ describe('$location', function() {
});
});
inject(function(){});
inject(function() {});
});
@@ -1875,7 +1875,7 @@ describe('$location', function() {
});
});
inject(function(){});
inject(function() {});
});
});

View File

@@ -2,7 +2,7 @@
'use strict';
function initService(debugEnabled) {
return module(function($logProvider){
return module(function($logProvider) {
$logProvider.debugEnabled(debugEnabled);
});
}
@@ -12,7 +12,7 @@ describe('$log', function() {
beforeEach(module(function($provide){
beforeEach(module(function($provide) {
$window = {navigator: {}, document: {}};
logger = '';
log = function() { logger+= 'log;'; };
@@ -27,7 +27,7 @@ describe('$log', function() {
}));
it('should use console if present', inject(
function(){
function() {
$window.console = {log: log,
warn: warn,
info: info,
@@ -46,7 +46,7 @@ describe('$log', function() {
it('should use console.log() if other not present', inject(
function(){
function() {
$window.console = {log: log};
},
function($log) {
@@ -122,7 +122,7 @@ describe('$log', function() {
beforeEach(initService(false));
it("should skip debugging output if disabled", inject(
function(){
function() {
$window.console = {log: log,
warn: warn,
info: info,

View File

@@ -259,12 +259,12 @@ describe('parser', function() {
expect(scope.$eval("0||1&&2")).toEqual(0||1&&2);
});
it('should parse ternary', function(){
var returnTrue = scope.returnTrue = function(){ return true; };
var returnFalse = scope.returnFalse = function(){ return false; };
var returnString = scope.returnString = function(){ return 'asd'; };
var returnInt = scope.returnInt = function(){ return 123; };
var identity = scope.identity = function(x){ return x; };
it('should parse ternary', function() {
var returnTrue = scope.returnTrue = function() { return true; };
var returnFalse = scope.returnFalse = function() { return false; };
var returnString = scope.returnString = function() { return 'asd'; };
var returnInt = scope.returnInt = function() { return 123; };
var identity = scope.identity = function(x) { return x; };
// Simple.
expect(scope.$eval('0?0:2')).toEqual(0?0:2);
@@ -463,7 +463,7 @@ describe('parser', function() {
});
it('should evaluate function call without arguments', function() {
scope['const'] = function(a, b){return 123;};
scope['const'] = function(a, b) {return 123;};
expect(scope.$eval("const()")).toEqual(123);
});
@@ -1246,7 +1246,7 @@ describe('parser', function() {
}));
describe('literal expressions', function () {
it('should only become stable when all the properties of an object have defined values', inject(function ($parse, $rootScope, log){
it('should only become stable when all the properties of an object have defined values', inject(function ($parse, $rootScope, log) {
var fn = $parse('::{foo: foo, bar: bar}');
$rootScope.$watch(fn, function(value) { log(value); }, true);
@@ -1274,7 +1274,7 @@ describe('parser', function() {
expect(log.empty()).toEqual([]);
}));
it('should only become stable when all the elements of an array have defined values', inject(function ($parse, $rootScope, log){
it('should only become stable when all the elements of an array have defined values', inject(function ($parse, $rootScope, log) {
var fn = $parse('::[foo,bar]');
$rootScope.$watch(fn, function(value) { log(value); }, true);

View File

@@ -679,7 +679,7 @@ describe('Scope', function() {
it('should watch array-like objects like arrays', function () {
var arrayLikelog = [];
$rootScope.$watchCollection('arrayLikeObject', function logger(obj) {
forEach(obj, function (element){
forEach(obj, function (element) {
arrayLikelog.push(element.name);
});
});
@@ -1699,7 +1699,7 @@ describe('Scope', function() {
expect(log).toEqual('2>1>0>');
});
it('should allow all events on the same scope to run even if stopPropagation is called', function(){
it('should allow all events on the same scope to run even if stopPropagation is called', function() {
child.$on('myEvent', logger);
grandChild.$on('myEvent', function(e) { e.stopPropagation(); });
grandChild.$on('myEvent', logger);

View File

@@ -117,7 +117,7 @@ describe("ngAnimate", function() {
};
}));
afterEach(function(){
afterEach(function() {
if (ss) {
ss.destroy();
}

View File

@@ -2,7 +2,7 @@
describe('$cookies', function() {
beforeEach(module('ngCookies', function($provide) {
$provide.factory('$browser', function(){
$provide.factory('$browser', function() {
return angular.extend(new angular.mock.$Browser(), {cookieHash: {preexisting:'oldCookie'}});
});
}));

View File

@@ -166,7 +166,7 @@ describe('ngMock', function() {
$logProvider.debugEnabled(debugEnabled);
}));
afterEach(inject(function($log){
afterEach(inject(function($log) {
$log.reset();
}));
@@ -195,7 +195,7 @@ describe('ngMock', function() {
$log = log;
}]));
afterEach(inject(function($log){
afterEach(inject(function($log) {
$log.reset();
}));
@@ -244,7 +244,7 @@ describe('ngMock', function() {
expect($log.debug.logs).toContain(['fake log']);
});
it('should assertEmpty', function(){
it('should assertEmpty', function() {
try {
$log.error(new Error('MyError'));
$log.warn(new Error('MyWarn'));
@@ -264,7 +264,7 @@ describe('ngMock', function() {
}
});
it('should reset state', function(){
it('should reset state', function() {
$log.error(new Error('MyError'));
$log.warn(new Error('MyWarn'));
$log.info(new Error('MyInfo'));
@@ -531,7 +531,7 @@ describe('ngMock', function() {
log = '';
}));
function logFn(text){
function logFn(text) {
return function() {
log += text +';';
};
@@ -588,7 +588,7 @@ describe('ngMock', function() {
}));
it('should log exceptions', module(function($exceptionHandlerProvider){
it('should log exceptions', module(function($exceptionHandlerProvider) {
$exceptionHandlerProvider.mode('log');
var $exceptionHandler = $exceptionHandlerProvider.$get();
$exceptionHandler('MyError');
@@ -623,7 +623,7 @@ describe('ngMock', function() {
}));
it('should throw an exception when not flushed', inject(function($timeout){
it('should throw an exception when not flushed', inject(function($timeout) {
$timeout(noop);
var expectedError = 'Deferred tasks to flush (1): {id: 0, time: 0}';
@@ -669,11 +669,11 @@ describe('ngMock', function() {
});
describe('angular.mock.dump', function(){
describe('angular.mock.dump', function() {
var d = angular.mock.dump;
it('should serialize primitive types', function(){
it('should serialize primitive types', function() {
expect(d(undefined)).toEqual('undefined');
expect(d(1)).toEqual('1');
expect(d(null)).toEqual('null');
@@ -681,19 +681,19 @@ describe('ngMock', function() {
});
it('should serialize element', function(){
it('should serialize element', function() {
var e = angular.element('<div>abc</div><span>xyz</span>');
expect(d(e).toLowerCase()).toEqual('<div>abc</div><span>xyz</span>');
expect(d(e[0]).toLowerCase()).toEqual('<div>abc</div>');
});
it('should serialize scope', inject(function($rootScope){
it('should serialize scope', inject(function($rootScope) {
$rootScope.obj = {abc:'123'};
expect(d($rootScope)).toMatch(/Scope\(.*\): \{/);
expect(d($rootScope)).toMatch(/{"abc":"123"}/);
}));
it('should serialize scope that has overridden "hasOwnProperty"', inject(function($rootScope, $sniffer){
it('should serialize scope that has overridden "hasOwnProperty"', inject(function($rootScope, $sniffer) {
/* jshint -W001 */
// MS IE8 just doesn't work for this kind of thing, since "for ... in" doesn't return
// things like hasOwnProperty even if it is explicitly defined on the actual object!
@@ -704,10 +704,10 @@ describe('ngMock', function() {
});
describe('jasmine module and inject', function(){
describe('jasmine module and inject', function() {
var log;
beforeEach(function(){
beforeEach(function() {
log = '';
});
@@ -816,7 +816,7 @@ describe('ngMock', function() {
});
describe('module with inject', function() {
beforeEach(module(function(){
beforeEach(module(function() {
log += 'module;';
}));

View File

@@ -1078,7 +1078,7 @@ describe("resource", function() {
expect(user).toEqualData([{id: 1, name: 'user1'}]);
});
it('should not require it if not provided', function(){
it('should not require it if not provided', function() {
$httpBackend.expect('GET', '/users.json').respond([{id: 1, name: 'user1'}]);
var UserService = $resource('/users.json');
var user = UserService.query();
@@ -1102,7 +1102,7 @@ describe("resource", function() {
expect(user).toEqualData([{id: 1, name: 'user1'}]);
});
it('should work with the action is overriden', function(){
it('should work with the action is overriden', function() {
$httpBackend.expect('GET', '/users.json').respond([{id: 1, name: 'user1'}]);
var UserService = $resource('/users/:user_id', {user_id: '@id'}, {
query: {
@@ -1138,7 +1138,7 @@ describe("resource", function() {
});
});
describe('get', function(){
describe('get', function() {
it('should add them to the id', function() {
$httpBackend.expect('GET', '/users/1.json').respond({id: 1, name: 'user1'});
var UserService = $resource('/users/:user_id.json', {user_id: '@id'});
@@ -1163,7 +1163,7 @@ describe("resource", function() {
expect(user).toEqualData({id: 1, name: 'user1'});
});
it('should work with the action is overriden', function(){
it('should work with the action is overriden', function() {
$httpBackend.expect('GET', '/users/1.json').respond({id: 1, name: 'user1'});
var UserService = $resource('/users/:user_id', {user_id: '@id'}, {
get: {

View File

@@ -12,7 +12,7 @@ describe('ngView', function() {
}));
afterEach(function(){
afterEach(function() {
dealoc(element);
});
@@ -673,7 +673,7 @@ describe('ngView animations', function() {
};
}));
afterEach(function(){
afterEach(function() {
dealoc(body);
dealoc(element);
});

View File

@@ -366,7 +366,7 @@ describe('$route', function() {
it('should chain whens and otherwise', function() {
module(function($routeProvider){
module(function($routeProvider) {
$routeProvider.when('/foo', {templateUrl: 'foo.html'}).
otherwise({templateUrl: 'bar.html'}).
when('/baz', {templateUrl: 'baz.html'});
@@ -432,7 +432,7 @@ describe('$route', function() {
it('should handle unknown routes with "otherwise" route definition', function() {
function NotFoundCtrl() {}
module(function($routeProvider){
module(function($routeProvider) {
$routeProvider.when('/foo', {templateUrl: 'foo.html'});
$routeProvider.otherwise({templateUrl: '404.html', controller: NotFoundCtrl});
});
@@ -463,7 +463,7 @@ describe('$route', function() {
it('should update $route.current and $route.next when default route is matched', function() {
module(function($routeProvider){
module(function($routeProvider) {
$routeProvider.when('/foo', {templateUrl: 'foo.html'});
$routeProvider.otherwise({templateUrl: '404.html'});
});
@@ -801,7 +801,7 @@ describe('$route', function() {
it('should match route with and without trailing slash', function() {
module(function($routeProvider){
module(function($routeProvider) {
$routeProvider.when('/foo', {templateUrl: 'foo.html'});
$routeProvider.when('/bar/', {templateUrl: 'bar.html'});
});
@@ -912,7 +912,7 @@ describe('$route', function() {
return '/custom';
}
module(function($routeProvider){
module(function($routeProvider) {
$routeProvider.when('/bar/:id/:subid/:subsubid', {templateUrl: 'bar.html'});
$routeProvider.when('/foo/:id', {redirectTo: customRedirectFn});
});
@@ -1106,7 +1106,7 @@ describe('$route', function() {
return 'foo.html';
}
module(function($routeProvider){
module(function($routeProvider) {
$routeProvider.when('/bar/:id/:subid/:subsubid', {templateUrl: 'bar.html'});
$routeProvider.when('/foo/:id', {templateUrl: customTemplateUrlFn});
});

View File

@@ -5,7 +5,7 @@ describe('linky', function() {
beforeEach(module('ngSanitize'));
beforeEach(inject(function($filter){
beforeEach(inject(function($filter) {
linky = $filter('linky');
}));

View File

@@ -6,7 +6,7 @@ describe('HTML', function() {
beforeEach(module('ngSanitize'));
beforeEach(function() {
expectHTML = function(html){
expectHTML = function(html) {
var sanitize;
inject(function($sanitize) {
sanitize = $sanitize;
@@ -23,7 +23,7 @@ describe('HTML', function() {
beforeEach(function() {
text = "";
handler = {
start: function(tag, attrs, unary){
start: function(tag, attrs, unary) {
start = {
tag: tag,
attrs: attrs,
@@ -35,7 +35,7 @@ describe('HTML', function() {
attrs[key] = value.replace(/^\s*/, '').replace(/\s*$/, '');
});
},
chars: function(text_){
chars: function(text_) {
text += text_;
},
end:function(tag) {
@@ -246,7 +246,7 @@ describe('HTML', function() {
beforeEach(function() {
html = '';
uriValidator = jasmine.createSpy('uriValidator');
writer = htmlSanitizeWriter({push:function(text){html+=text;}}, uriValidator);
writer = htmlSanitizeWriter({push:function(text) {html+=text;}}, uriValidator);
});
it('should write basic HTML', function() {
@@ -473,7 +473,7 @@ describe('decodeEntities', function() {
text = '';
handler = {
start: function() {},
chars: function(text_){
chars: function(text_) {
text = text_;
},
end: function() {},

View File

@@ -14,7 +14,7 @@ describe('angular.scenario.Describe', function() {
log.text = log.text + text;
};
log.fn = function(text) {
return function(done){
return function(done) {
log(text);
(done || angular.noop)();
};

View File

@@ -56,7 +56,7 @@ describe("angular.scenario.dsl", function() {
jqLite($window.document).empty();
}));
afterEach(function(){
afterEach(function() {
jqLite($window.document).removeData('$injector');
});
@@ -282,7 +282,7 @@ describe("angular.scenario.dsl", function() {
expect($root.futureError).toMatch(/did not match/);
});
it('should fail to select an option that does not exist', function(){
it('should fail to select an option that does not exist', function() {
doc.append(
'<select ng-model="test">' +
' <option value=A>one</option>' +

View File

@@ -43,7 +43,7 @@ describe('angular.scenario.matchers', function () {
expectMatcher(3, function() { matchers.toBeGreaterThan(-5); });
});
it('should have toHaveClass matcher', function(){
it('should have toHaveClass matcher', function() {
var e = angular.element('<div class="abc">');
expect(e).not.toHaveClass('none');
expect(e).toHaveClass('abc');