summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadomir Dopieralski <openstack@sheep.art.pl>2014-08-13 13:08:00 +0200
committerRadomir Dopieralski <openstack@sheep.art.pl>2014-08-13 13:08:00 +0200
commit3dcfb608924b84ea2a075f0f06fb57e44ea8d0e9 (patch)
tree68db53b3dd04ee0e395eb3cf194c0c00b42182a6
parentb7e3a0e79073b6c1efbdddd81ed03a97429dc55e (diff)
downloadxstatic-angular-mock-3dcfb608924b84ea2a075f0f06fb57e44ea8d0e9.tar.gz
Version 1.2.16.0
Change-Id: I0dccab7535314d37136e336920bec7d3d678139c
-rw-r--r--xstatic/pkg/angular_mock/__init__.py4
-rw-r--r--xstatic/pkg/angular_mock/data/angular-mock.js804
2 files changed, 428 insertions, 380 deletions
diff --git a/xstatic/pkg/angular_mock/__init__.py b/xstatic/pkg/angular_mock/__init__.py
index b79cf0c..ef8b54f 100644
--- a/xstatic/pkg/angular_mock/__init__.py
+++ b/xstatic/pkg/angular_mock/__init__.py
@@ -11,9 +11,9 @@ NAME = __name__.split('.')[-1] # package name (e.g. 'foo' or 'foo_bar')
# please use a all-lowercase valid python
# package name
-VERSION = '1.2.1' # version of the packaged files, please use the upstream
+VERSION = '1.2.16' # version of the packaged files, please use the upstream
# version number
-BUILD = '1' # our package build number, so we can release new builds
+BUILD = '0' # our package build number, so we can release new builds
# with fixes for xstatic stuff.
PACKAGE_VERSION = VERSION + '.' + BUILD # version used for PyPi
diff --git a/xstatic/pkg/angular_mock/data/angular-mock.js b/xstatic/pkg/angular_mock/data/angular-mock.js
index 3dfdf49..da804b4 100644
--- a/xstatic/pkg/angular_mock/data/angular-mock.js
+++ b/xstatic/pkg/angular_mock/data/angular-mock.js
@@ -1,15 +1,14 @@
-'use strict';
-
/**
- * @license AngularJS v1.2.1
- * (c) 2010-2012 Google, Inc. http://angularjs.org
+ * @license AngularJS v1.2.16
+ * (c) 2010-2014 Google, Inc. http://angularjs.org
* License: MIT
- *
- * TODO(vojta): wrap whole file into closure during build
*/
+(function(window, angular, undefined) {
+
+'use strict';
/**
- * @ngdoc overview
+ * @ngdoc object
* @name angular.mock
* @description
*
@@ -20,7 +19,7 @@ angular.mock = {};
/**
* ! This is a private undocumented service !
*
- * @name ngMock.$browser
+ * @name $browser
*
* @description
* This service is a mock implementation of {@link ng.$browser}. It provides fake
@@ -78,8 +77,7 @@ angular.mock.$Browser = function() {
/**
- * @name ngMock.$browser#defer.now
- * @propertyOf ngMock.$browser
+ * @name $browser#defer.now
*
* @description
* Current milliseconds mock time.
@@ -104,8 +102,7 @@ angular.mock.$Browser = function() {
/**
- * @name ngMock.$browser#defer.flush
- * @methodOf ngMock.$browser
+ * @name $browser#defer.flush
*
* @description
* Flushes all pending requests and executes the defer callbacks.
@@ -136,8 +133,7 @@ angular.mock.$Browser = function() {
angular.mock.$Browser.prototype = {
/**
- * @name ngMock.$browser#poll
- * @methodOf ngMock.$browser
+ * @name $browser#poll
*
* @description
* run all fns in pollFns
@@ -188,8 +184,8 @@ angular.mock.$Browser.prototype = {
/**
- * @ngdoc object
- * @name ngMock.$exceptionHandlerProvider
+ * @ngdoc provider
+ * @name $exceptionHandlerProvider
*
* @description
* Configures the mock implementation of {@link ng.$exceptionHandler} to rethrow or to log errors
@@ -197,8 +193,8 @@ angular.mock.$Browser.prototype = {
*/
/**
- * @ngdoc object
- * @name ngMock.$exceptionHandler
+ * @ngdoc service
+ * @name $exceptionHandler
*
* @description
* Mock implementation of {@link ng.$exceptionHandler} that rethrows or logs errors passed
@@ -206,7 +202,7 @@ angular.mock.$Browser.prototype = {
* information.
*
*
- * <pre>
+ * ```js
* describe('$exceptionHandlerProvider', function() {
*
* it('should capture log messages and exceptions', function() {
@@ -227,7 +223,7 @@ angular.mock.$Browser.prototype = {
* });
* });
* });
- * </pre>
+ * ```
*/
angular.mock.$ExceptionHandlerProvider = function() {
@@ -235,8 +231,7 @@ angular.mock.$ExceptionHandlerProvider = function() {
/**
* @ngdoc method
- * @name ngMock.$exceptionHandlerProvider#mode
- * @methodOf ngMock.$exceptionHandlerProvider
+ * @name $exceptionHandlerProvider#mode
*
* @description
* Sets the logging mode.
@@ -286,7 +281,7 @@ angular.mock.$ExceptionHandlerProvider = function() {
/**
* @ngdoc service
- * @name ngMock.$log
+ * @name $log
*
* @description
* Mock implementation of {@link ng.$log} that gathers all logged messages in arrays
@@ -325,8 +320,7 @@ angular.mock.$LogProvider = function() {
/**
* @ngdoc method
- * @name ngMock.$log#reset
- * @methodOf ngMock.$log
+ * @name $log#reset
*
* @description
* Reset all of the logging arrays to empty.
@@ -334,85 +328,79 @@ angular.mock.$LogProvider = function() {
$log.reset = function () {
/**
* @ngdoc property
- * @name ngMock.$log#log.logs
- * @propertyOf ngMock.$log
+ * @name $log#log.logs
*
* @description
* Array of messages logged using {@link ngMock.$log#log}.
*
* @example
- * <pre>
+ * ```js
* $log.log('Some Log');
* var first = $log.log.logs.unshift();
- * </pre>
+ * ```
*/
$log.log.logs = [];
/**
* @ngdoc property
- * @name ngMock.$log#info.logs
- * @propertyOf ngMock.$log
+ * @name $log#info.logs
*
* @description
* Array of messages logged using {@link ngMock.$log#info}.
*
* @example
- * <pre>
+ * ```js
* $log.info('Some Info');
* var first = $log.info.logs.unshift();
- * </pre>
+ * ```
*/
$log.info.logs = [];
/**
* @ngdoc property
- * @name ngMock.$log#warn.logs
- * @propertyOf ngMock.$log
+ * @name $log#warn.logs
*
* @description
* Array of messages logged using {@link ngMock.$log#warn}.
*
* @example
- * <pre>
+ * ```js
* $log.warn('Some Warning');
* var first = $log.warn.logs.unshift();
- * </pre>
+ * ```
*/
$log.warn.logs = [];
/**
* @ngdoc property
- * @name ngMock.$log#error.logs
- * @propertyOf ngMock.$log
+ * @name $log#error.logs
*
* @description
* Array of messages logged using {@link ngMock.$log#error}.
*
* @example
- * <pre>
- * $log.log('Some Error');
+ * ```js
+ * $log.error('Some Error');
* var first = $log.error.logs.unshift();
- * </pre>
+ * ```
*/
$log.error.logs = [];
/**
* @ngdoc property
- * @name ngMock.$log#debug.logs
- * @propertyOf ngMock.$log
+ * @name $log#debug.logs
*
* @description
* Array of messages logged using {@link ngMock.$log#debug}.
*
* @example
- * <pre>
+ * ```js
* $log.debug('Some Error');
* var first = $log.debug.logs.unshift();
- * </pre>
+ * ```
*/
$log.debug.logs = [];
};
/**
* @ngdoc method
- * @name ngMock.$log#assertEmpty
- * @methodOf ngMock.$log
+ * @name $log#assertEmpty
*
* @description
* Assert that the all of the logging methods have no logged messages. If messages present, an
@@ -444,12 +432,12 @@ angular.mock.$LogProvider = function() {
/**
* @ngdoc service
- * @name ngMock.$interval
+ * @name $interval
*
* @description
* Mock implementation of the $interval service.
*
- * Use {@link ngMock.$interval#methods_flush `$interval.flush(millis)`} to
+ * Use {@link ngMock.$interval#flush `$interval.flush(millis)`} to
* move forward by `millis` milliseconds and trigger any functions scheduled to run in that
* time.
*
@@ -458,7 +446,7 @@ angular.mock.$LogProvider = function() {
* @param {number=} [count=0] Number of times to repeat. If not set, or 0, will repeat
* indefinitely.
* @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise
- * will invoke `fn` within the {@link ng.$rootScope.Scope#methods_$apply $apply} block.
+ * will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block.
* @returns {promise} A promise which will be notified on each iteration.
*/
angular.mock.$IntervalProvider = function() {
@@ -510,8 +498,18 @@ angular.mock.$IntervalProvider = function() {
nextRepeatId++;
return promise;
};
-
+ /**
+ * @ngdoc method
+ * @name $interval#cancel
+ *
+ * @description
+ * Cancels a task associated with the `promise`.
+ *
+ * @param {promise} promise A promise from calling the `$interval` function.
+ * @returns {boolean} Returns `true` if the task was successfully cancelled.
+ */
$interval.cancel = function(promise) {
+ if(!promise) return false;
var fnIndex;
angular.forEach(repeatFns, function(fn, index) {
@@ -529,8 +527,7 @@ angular.mock.$IntervalProvider = function() {
/**
* @ngdoc method
- * @name ngMock.$interval#flush
- * @methodOf ngMock.$interval
+ * @name $interval#flush
* @description
*
* Runs interval tasks scheduled to be run in the next `millis` milliseconds.
@@ -560,246 +557,247 @@ angular.mock.$IntervalProvider = function() {
* This directive should go inside the anonymous function but a bug in JSHint means that it would
* not be enacted early enough to prevent the warning.
*/
-(function() {
- var R_ISO8061_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?:\:?(\d\d)(?:\:?(\d\d)(?:\.(\d{3}))?)?)?(Z|([+-])(\d\d):?(\d\d)))?$/;
-
- function jsonStringToDate(string) {
- var match;
- if (match = string.match(R_ISO8061_STR)) {
- var date = new Date(0),
- tzHour = 0,
- tzMin = 0;
- if (match[9]) {
- tzHour = int(match[9] + match[10]);
- tzMin = int(match[9] + match[11]);
- }
- date.setUTCFullYear(int(match[1]), int(match[2]) - 1, int(match[3]));
- date.setUTCHours(int(match[4]||0) - tzHour,
- int(match[5]||0) - tzMin,
- int(match[6]||0),
- int(match[7]||0));
- return date;
+var R_ISO8061_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?:\:?(\d\d)(?:\:?(\d\d)(?:\.(\d{3}))?)?)?(Z|([+-])(\d\d):?(\d\d)))?$/;
+
+function jsonStringToDate(string) {
+ var match;
+ if (match = string.match(R_ISO8061_STR)) {
+ var date = new Date(0),
+ tzHour = 0,
+ tzMin = 0;
+ if (match[9]) {
+ tzHour = int(match[9] + match[10]);
+ tzMin = int(match[9] + match[11]);
}
- return string;
+ date.setUTCFullYear(int(match[1]), int(match[2]) - 1, int(match[3]));
+ date.setUTCHours(int(match[4]||0) - tzHour,
+ int(match[5]||0) - tzMin,
+ int(match[6]||0),
+ int(match[7]||0));
+ return date;
}
+ return string;
+}
- function int(str) {
- return parseInt(str, 10);
+function int(str) {
+ return parseInt(str, 10);
+}
+
+function padNumber(num, digits, trim) {
+ var neg = '';
+ if (num < 0) {
+ neg = '-';
+ num = -num;
}
+ num = '' + num;
+ while(num.length < digits) num = '0' + num;
+ if (trim)
+ num = num.substr(num.length - digits);
+ return neg + num;
+}
- function padNumber(num, digits, trim) {
- var neg = '';
- if (num < 0) {
- neg = '-';
- num = -num;
- }
- num = '' + num;
- while(num.length < digits) num = '0' + num;
- if (trim)
- num = num.substr(num.length - digits);
- return neg + num;
+
+/**
+ * @ngdoc type
+ * @name angular.mock.TzDate
+ * @description
+ *
+ * *NOTE*: this is not an injectable instance, just a globally available mock class of `Date`.
+ *
+ * Mock of the Date type which has its timezone specified via constructor arg.
+ *
+ * The main purpose is to create Date-like instances with timezone fixed to the specified timezone
+ * offset, so that we can test code that depends on local timezone settings without dependency on
+ * the time zone settings of the machine where the code is running.
+ *
+ * @param {number} offset Offset of the *desired* timezone in hours (fractions will be honored)
+ * @param {(number|string)} timestamp Timestamp representing the desired time in *UTC*
+ *
+ * @example
+ * !!!! WARNING !!!!!
+ * This is not a complete Date object so only methods that were implemented can be called safely.
+ * To make matters worse, TzDate instances inherit stuff from Date via a prototype.
+ *
+ * We do our best to intercept calls to "unimplemented" methods, but since the list of methods is
+ * incomplete we might be missing some non-standard methods. This can result in errors like:
+ * "Date.prototype.foo called on incompatible Object".
+ *
+ * ```js
+ * var newYearInBratislava = new TzDate(-1, '2009-12-31T23:00:00Z');
+ * newYearInBratislava.getTimezoneOffset() => -60;
+ * newYearInBratislava.getFullYear() => 2010;
+ * newYearInBratislava.getMonth() => 0;
+ * newYearInBratislava.getDate() => 1;
+ * newYearInBratislava.getHours() => 0;
+ * newYearInBratislava.getMinutes() => 0;
+ * newYearInBratislava.getSeconds() => 0;
+ * ```
+ *
+ */
+angular.mock.TzDate = function (offset, timestamp) {
+ var self = new Date(0);
+ if (angular.isString(timestamp)) {
+ var tsStr = timestamp;
+
+ self.origDate = jsonStringToDate(timestamp);
+
+ timestamp = self.origDate.getTime();
+ if (isNaN(timestamp))
+ throw {
+ name: "Illegal Argument",
+ message: "Arg '" + tsStr + "' passed into TzDate constructor is not a valid date string"
+ };
+ } else {
+ self.origDate = new Date(timestamp);
}
+ var localOffset = new Date(timestamp).getTimezoneOffset();
+ self.offsetDiff = localOffset*60*1000 - offset*1000*60*60;
+ self.date = new Date(timestamp + self.offsetDiff);
- /**
- * @ngdoc object
- * @name angular.mock.TzDate
- * @description
- *
- * *NOTE*: this is not an injectable instance, just a globally available mock class of `Date`.
- *
- * Mock of the Date type which has its timezone specified via constructor arg.
- *
- * The main purpose is to create Date-like instances with timezone fixed to the specified timezone
- * offset, so that we can test code that depends on local timezone settings without dependency on
- * the time zone settings of the machine where the code is running.
- *
- * @param {number} offset Offset of the *desired* timezone in hours (fractions will be honored)
- * @param {(number|string)} timestamp Timestamp representing the desired time in *UTC*
- *
- * @example
- * !!!! WARNING !!!!!
- * This is not a complete Date object so only methods that were implemented can be called safely.
- * To make matters worse, TzDate instances inherit stuff from Date via a prototype.
- *
- * We do our best to intercept calls to "unimplemented" methods, but since the list of methods is
- * incomplete we might be missing some non-standard methods. This can result in errors like:
- * "Date.prototype.foo called on incompatible Object".
- *
- * <pre>
- * var newYearInBratislava = new TzDate(-1, '2009-12-31T23:00:00Z');
- * newYearInBratislava.getTimezoneOffset() => -60;
- * newYearInBratislava.getFullYear() => 2010;
- * newYearInBratislava.getMonth() => 0;
- * newYearInBratislava.getDate() => 1;
- * newYearInBratislava.getHours() => 0;
- * newYearInBratislava.getMinutes() => 0;
- * newYearInBratislava.getSeconds() => 0;
- * </pre>
- *
- */
- angular.mock.TzDate = function (offset, timestamp) {
- var self = new Date(0);
- if (angular.isString(timestamp)) {
- var tsStr = timestamp;
-
- self.origDate = jsonStringToDate(timestamp);
-
- timestamp = self.origDate.getTime();
- if (isNaN(timestamp))
- throw {
- name: "Illegal Argument",
- message: "Arg '" + tsStr + "' passed into TzDate constructor is not a valid date string"
- };
- } else {
- self.origDate = new Date(timestamp);
- }
+ self.getTime = function() {
+ return self.date.getTime() - self.offsetDiff;
+ };
- var localOffset = new Date(timestamp).getTimezoneOffset();
- self.offsetDiff = localOffset*60*1000 - offset*1000*60*60;
- self.date = new Date(timestamp + self.offsetDiff);
+ self.toLocaleDateString = function() {
+ return self.date.toLocaleDateString();
+ };
- self.getTime = function() {
- return self.date.getTime() - self.offsetDiff;
- };
+ self.getFullYear = function() {
+ return self.date.getFullYear();
+ };
- self.toLocaleDateString = function() {
- return self.date.toLocaleDateString();
- };
+ self.getMonth = function() {
+ return self.date.getMonth();
+ };
- self.getFullYear = function() {
- return self.date.getFullYear();
- };
+ self.getDate = function() {
+ return self.date.getDate();
+ };
- self.getMonth = function() {
- return self.date.getMonth();
- };
+ self.getHours = function() {
+ return self.date.getHours();
+ };
- self.getDate = function() {
- return self.date.getDate();
- };
+ self.getMinutes = function() {
+ return self.date.getMinutes();
+ };
- self.getHours = function() {
- return self.date.getHours();
- };
+ self.getSeconds = function() {
+ return self.date.getSeconds();
+ };
- self.getMinutes = function() {
- return self.date.getMinutes();
- };
+ self.getMilliseconds = function() {
+ return self.date.getMilliseconds();
+ };
- self.getSeconds = function() {
- return self.date.getSeconds();
- };
+ self.getTimezoneOffset = function() {
+ return offset * 60;
+ };
- self.getMilliseconds = function() {
- return self.date.getMilliseconds();
- };
+ self.getUTCFullYear = function() {
+ return self.origDate.getUTCFullYear();
+ };
- self.getTimezoneOffset = function() {
- return offset * 60;
- };
+ self.getUTCMonth = function() {
+ return self.origDate.getUTCMonth();
+ };
- self.getUTCFullYear = function() {
- return self.origDate.getUTCFullYear();
- };
+ self.getUTCDate = function() {
+ return self.origDate.getUTCDate();
+ };
- self.getUTCMonth = function() {
- return self.origDate.getUTCMonth();
- };
+ self.getUTCHours = function() {
+ return self.origDate.getUTCHours();
+ };
- self.getUTCDate = function() {
- return self.origDate.getUTCDate();
- };
+ self.getUTCMinutes = function() {
+ return self.origDate.getUTCMinutes();
+ };
- self.getUTCHours = function() {
- return self.origDate.getUTCHours();
- };
+ self.getUTCSeconds = function() {
+ return self.origDate.getUTCSeconds();
+ };
- self.getUTCMinutes = function() {
- return self.origDate.getUTCMinutes();
- };
+ self.getUTCMilliseconds = function() {
+ return self.origDate.getUTCMilliseconds();
+ };
- self.getUTCSeconds = function() {
- return self.origDate.getUTCSeconds();
- };
+ self.getDay = function() {
+ return self.date.getDay();
+ };
- self.getUTCMilliseconds = function() {
- return self.origDate.getUTCMilliseconds();
+ // provide this method only on browsers that already have it
+ if (self.toISOString) {
+ self.toISOString = function() {
+ return padNumber(self.origDate.getUTCFullYear(), 4) + '-' +
+ padNumber(self.origDate.getUTCMonth() + 1, 2) + '-' +
+ padNumber(self.origDate.getUTCDate(), 2) + 'T' +
+ padNumber(self.origDate.getUTCHours(), 2) + ':' +
+ padNumber(self.origDate.getUTCMinutes(), 2) + ':' +
+ padNumber(self.origDate.getUTCSeconds(), 2) + '.' +
+ padNumber(self.origDate.getUTCMilliseconds(), 3) + 'Z';
};
+ }
- self.getDay = function() {
- return self.date.getDay();
+ //hide all methods not implemented in this mock that the Date prototype exposes
+ var unimplementedMethods = ['getUTCDay',
+ 'getYear', 'setDate', 'setFullYear', 'setHours', 'setMilliseconds',
+ 'setMinutes', 'setMonth', 'setSeconds', 'setTime', 'setUTCDate', 'setUTCFullYear',
+ 'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds',
+ 'setYear', 'toDateString', 'toGMTString', 'toJSON', 'toLocaleFormat', 'toLocaleString',
+ 'toLocaleTimeString', 'toSource', 'toString', 'toTimeString', 'toUTCString', 'valueOf'];
+
+ angular.forEach(unimplementedMethods, function(methodName) {
+ self[methodName] = function() {
+ throw new Error("Method '" + methodName + "' is not implemented in the TzDate mock");
};
+ });
- // provide this method only on browsers that already have it
- if (self.toISOString) {
- self.toISOString = function() {
- return padNumber(self.origDate.getUTCFullYear(), 4) + '-' +
- padNumber(self.origDate.getUTCMonth() + 1, 2) + '-' +
- padNumber(self.origDate.getUTCDate(), 2) + 'T' +
- padNumber(self.origDate.getUTCHours(), 2) + ':' +
- padNumber(self.origDate.getUTCMinutes(), 2) + ':' +
- padNumber(self.origDate.getUTCSeconds(), 2) + '.' +
- padNumber(self.origDate.getUTCMilliseconds(), 3) + 'Z';
- };
- }
-
- //hide all methods not implemented in this mock that the Date prototype exposes
- var unimplementedMethods = ['getUTCDay',
- 'getYear', 'setDate', 'setFullYear', 'setHours', 'setMilliseconds',
- 'setMinutes', 'setMonth', 'setSeconds', 'setTime', 'setUTCDate', 'setUTCFullYear',
- 'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds',
- 'setYear', 'toDateString', 'toGMTString', 'toJSON', 'toLocaleFormat', 'toLocaleString',
- 'toLocaleTimeString', 'toSource', 'toString', 'toTimeString', 'toUTCString', 'valueOf'];
-
- angular.forEach(unimplementedMethods, function(methodName) {
- self[methodName] = function() {
- throw new Error("Method '" + methodName + "' is not implemented in the TzDate mock");
- };
- });
-
- return self;
- };
+ return self;
+};
- //make "tzDateInstance instanceof Date" return true
- angular.mock.TzDate.prototype = Date.prototype;
-})();
+//make "tzDateInstance instanceof Date" return true
+angular.mock.TzDate.prototype = Date.prototype;
/* jshint +W101 */
-angular.mock.animate = angular.module('mock.animate', ['ng'])
+angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
.config(['$provide', function($provide) {
- $provide.decorator('$animate', function($delegate) {
+ var reflowQueue = [];
+ $provide.value('$$animateReflow', function(fn) {
+ var index = reflowQueue.length;
+ reflowQueue.push(fn);
+ return function cancel() {
+ reflowQueue.splice(index, 1);
+ };
+ });
+
+ $provide.decorator('$animate', function($delegate, $$asyncCallback) {
var animate = {
queue : [],
enabled : $delegate.enabled,
- flushNext : function(name) {
- var tick = animate.queue.shift();
-
- if (!tick) throw new Error('No animation to be flushed');
- if(tick.method !== name) {
- throw new Error('The next animation is not "' + name +
- '", but is "' + tick.method + '"');
- }
- tick.fn();
- return tick;
+ triggerCallbacks : function() {
+ $$asyncCallback.flush();
+ },
+ triggerReflow : function() {
+ angular.forEach(reflowQueue, function(fn) {
+ fn();
+ });
+ reflowQueue = [];
}
};
- angular.forEach(['enter','leave','move','addClass','removeClass'], function(method) {
+ angular.forEach(
+ ['enter','leave','move','addClass','removeClass','setClass'], function(method) {
animate[method] = function() {
- var params = arguments;
animate.queue.push({
- method : method,
- params : params,
- element : angular.isElement(params[0]) && params[0],
- parent : angular.isElement(params[1]) && params[1],
- after : angular.isElement(params[2]) && params[2],
- fn : function() {
- $delegate[method].apply($delegate, params);
- }
+ event : method,
+ element : arguments[0],
+ args : arguments
});
+ $delegate[method].apply($delegate, arguments);
};
});
@@ -880,8 +878,8 @@ angular.mock.dump = function(object) {
};
/**
- * @ngdoc object
- * @name ngMock.$httpBackend
+ * @ngdoc service
+ * @name $httpBackend
* @description
* Fake HTTP backend implementation suitable for unit testing applications that use the
* {@link ng.$http $http service}.
@@ -890,8 +888,8 @@ angular.mock.dump = function(object) {
* development please see {@link ngMockE2E.$httpBackend e2e $httpBackend mock}.
*
* During unit testing, we want our unit tests to run quickly and have no external dependencies so
- * we don’t want to send {@link https://developer.mozilla.org/en/xmlhttprequest XHR} or
- * {@link http://en.wikipedia.org/wiki/JSONP JSONP} requests to a real server. All we really need is
+ * we don’t want to send [XHR](https://developer.mozilla.org/en/xmlhttprequest) or
+ * [JSONP](http://en.wikipedia.org/wiki/JSONP) requests to a real server. All we really need is
* to verify whether a certain request has been sent or not, or alternatively just let the
* application make requests, respond with pre-trained responses and assert that the end result is
* what we expect it to be.
@@ -969,20 +967,19 @@ angular.mock.dump = function(object) {
*
* # Flushing HTTP requests
*
- * The $httpBackend used in production, always responds to requests with responses asynchronously.
- * If we preserved this behavior in unit testing, we'd have to create async unit tests, which are
- * hard to write, follow and maintain. At the same time the testing mock, can't respond
- * synchronously because that would change the execution of the code under test. For this reason the
- * mock $httpBackend has a `flush()` method, which allows the test to explicitly flush pending
- * requests and thus preserving the async api of the backend, while allowing the test to execute
- * synchronously.
+ * The $httpBackend used in production always responds to requests asynchronously. If we preserved
+ * this behavior in unit testing, we'd have to create async unit tests, which are hard to write,
+ * to follow and to maintain. But neither can the testing mock respond synchronously; that would
+ * change the execution of the code under test. For this reason, the mock $httpBackend has a
+ * `flush()` method, which allows the test to explicitly flush pending requests. This preserves
+ * the async api of the backend, while allowing the test to execute synchronously.
*
*
* # Unit testing with mock $httpBackend
- * The following code shows how to setup and use the mock backend in unit testing a controller.
- * First we create the controller under test
+ * The following code shows how to setup and use the mock backend when unit testing a controller.
+ * First we create the controller under test:
*
- <pre>
+ ```js
// The controller code
function MyController($scope, $http) {
var authToken;
@@ -1003,11 +1000,11 @@ angular.mock.dump = function(object) {
});
};
}
- </pre>
+ ```
*
- * Now we setup the mock backend and create the test specs.
+ * Now we setup the mock backend and create the test specs:
*
- <pre>
+ ```js
// testing controller
describe('MyController', function() {
var $httpBackend, $rootScope, createController;
@@ -1046,7 +1043,7 @@ angular.mock.dump = function(object) {
var controller = createController();
$httpBackend.flush();
- // now you don’t care about the authentication, but
+ // now you don’t care about the authentication, but
// the controller will still send the request and
// $httpBackend will respond without you having to
// specify the expectation and response for this request
@@ -1073,7 +1070,7 @@ angular.mock.dump = function(object) {
$httpBackend.flush();
});
});
- </pre>
+ ```
*/
angular.mock.$HttpBackendProvider = function() {
this.$get = ['$rootScope', createHttpBackendMock];
@@ -1097,14 +1094,15 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
var definitions = [],
expectations = [],
responses = [],
- responsesPush = angular.bind(responses, responses.push);
+ responsesPush = angular.bind(responses, responses.push),
+ copy = angular.copy;
- function createResponse(status, data, headers) {
+ function createResponse(status, data, headers, statusText) {
if (angular.isFunction(status)) return status;
return function() {
return angular.isNumber(status)
- ? [status, data, headers]
+ ? [status, data, headers, statusText]
: [200, status, data];
};
}
@@ -1129,7 +1127,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
function handleResponse() {
var response = wrapped.response(method, url, data, headers);
xhr.$$respHeaders = response[2];
- callback(response[0], response[1], xhr.getAllResponseHeaders());
+ callback(copy(response[0]), copy(response[1]), xhr.getAllResponseHeaders(),
+ copy(response[3] || ''));
}
function handleTimeout() {
@@ -1182,8 +1181,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#when
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#when
* @description
* Creates a new backend definition.
*
@@ -1196,17 +1194,18 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled.
*
- * - respond –
- * `{function([status,] data[, headers])|function(function(method, url, data, headers)}`
- * – The respond method takes a set of static data to be returned or a function that can return
- * an array containing response status (number), response data (string) and response headers
- * (Object).
+ * - respond –
+ * `{function([status,] data[, headers, statusText])
+ * | function(function(method, url, data, headers)}`
+ * – The respond method takes a set of static data to be returned or a function that can
+ * return an array containing response status (number), response data (string), response
+ * headers (Object), and the text for the status (string).
*/
$httpBackend.when = function(method, url, data, headers) {
var definition = new MockHttpExpectation(method, url, data, headers),
chain = {
- respond: function(status, data, headers) {
- definition.response = createResponse(status, data, headers);
+ respond: function(status, data, headers, statusText) {
+ definition.response = createResponse(status, data, headers, statusText);
}
};
@@ -1222,8 +1221,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#whenGET
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#whenGET
* @description
* Creates a new backend definition for GET requests. For more info see `when()`.
*
@@ -1235,8 +1233,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#whenHEAD
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#whenHEAD
* @description
* Creates a new backend definition for HEAD requests. For more info see `when()`.
*
@@ -1248,8 +1245,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#whenDELETE
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#whenDELETE
* @description
* Creates a new backend definition for DELETE requests. For more info see `when()`.
*
@@ -1261,8 +1257,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#whenPOST
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#whenPOST
* @description
* Creates a new backend definition for POST requests. For more info see `when()`.
*
@@ -1276,8 +1271,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#whenPUT
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#whenPUT
* @description
* Creates a new backend definition for PUT requests. For more info see `when()`.
*
@@ -1291,8 +1285,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#whenJSONP
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#whenJSONP
* @description
* Creates a new backend definition for JSONP requests. For more info see `when()`.
*
@@ -1305,8 +1298,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#expect
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#expect
* @description
* Creates a new request expectation.
*
@@ -1320,18 +1312,19 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
* request is handled.
*
- * - respond –
- * `{function([status,] data[, headers])|function(function(method, url, data, headers)}`
- * – The respond method takes a set of static data to be returned or a function that can return
- * an array containing response status (number), response data (string) and response headers
- * (Object).
+ * - respond –
+ * `{function([status,] data[, headers, statusText])
+ * | function(function(method, url, data, headers)}`
+ * – The respond method takes a set of static data to be returned or a function that can
+ * return an array containing response status (number), response data (string), response
+ * headers (Object), and the text for the status (string).
*/
$httpBackend.expect = function(method, url, data, headers) {
var expectation = new MockHttpExpectation(method, url, data, headers);
expectations.push(expectation);
return {
- respond: function(status, data, headers) {
- expectation.response = createResponse(status, data, headers);
+ respond: function (status, data, headers, statusText) {
+ expectation.response = createResponse(status, data, headers, statusText);
}
};
};
@@ -1339,8 +1332,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#expectGET
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#expectGET
* @description
* Creates a new request expectation for GET requests. For more info see `expect()`.
*
@@ -1352,8 +1344,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#expectHEAD
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#expectHEAD
* @description
* Creates a new request expectation for HEAD requests. For more info see `expect()`.
*
@@ -1365,8 +1356,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#expectDELETE
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#expectDELETE
* @description
* Creates a new request expectation for DELETE requests. For more info see `expect()`.
*
@@ -1378,8 +1368,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#expectPOST
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#expectPOST
* @description
* Creates a new request expectation for POST requests. For more info see `expect()`.
*
@@ -1394,8 +1383,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#expectPUT
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#expectPUT
* @description
* Creates a new request expectation for PUT requests. For more info see `expect()`.
*
@@ -1410,8 +1398,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#expectPATCH
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#expectPATCH
* @description
* Creates a new request expectation for PATCH requests. For more info see `expect()`.
*
@@ -1426,8 +1413,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#expectJSONP
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#expectJSONP
* @description
* Creates a new request expectation for JSONP requests. For more info see `expect()`.
*
@@ -1440,8 +1426,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#flush
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#flush
* @description
* Flushes all pending requests using the trained responses.
*
@@ -1469,8 +1454,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#verifyNoOutstandingExpectation
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#verifyNoOutstandingExpectation
* @description
* Verifies that all of the requests defined via the `expect` api were made. If any of the
* requests were not made, verifyNoOutstandingExpectation throws an exception.
@@ -1478,9 +1462,9 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
* Typically, you would call this method following each test case that asserts requests using an
* "afterEach" clause.
*
- * <pre>
+ * ```js
* afterEach($httpBackend.verifyNoOutstandingExpectation);
- * </pre>
+ * ```
*/
$httpBackend.verifyNoOutstandingExpectation = function() {
$rootScope.$digest();
@@ -1492,17 +1476,16 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#verifyNoOutstandingRequest
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#verifyNoOutstandingRequest
* @description
* Verifies that there are no outstanding requests that need to be flushed.
*
* Typically, you would call this method following each test case that asserts requests using an
* "afterEach" clause.
*
- * <pre>
+ * ```js
* afterEach($httpBackend.verifyNoOutstandingRequest);
- * </pre>
+ * ```
*/
$httpBackend.verifyNoOutstandingRequest = function() {
if (responses.length) {
@@ -1513,8 +1496,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$httpBackend#resetExpectations
- * @methodOf ngMock.$httpBackend
+ * @name $httpBackend#resetExpectations
* @description
* Resets all request expectations, but preserves all backend definitions. Typically, you would
* call resetExpectations during a multiple-phase test when you want to reuse the same instance of
@@ -1572,7 +1554,7 @@ function MockHttpExpectation(method, url, data, headers) {
if (angular.isUndefined(data)) return true;
if (data && angular.isFunction(data.test)) return data.test(d);
if (data && angular.isFunction(data)) return data(d);
- if (data && !angular.isString(data)) return angular.toJson(data) == d;
+ if (data && !angular.isString(data)) return angular.equals(data, angular.fromJson(d));
return data == d;
};
@@ -1581,6 +1563,10 @@ function MockHttpExpectation(method, url, data, headers) {
};
}
+function createMockXhr() {
+ return new MockXhr();
+}
+
function MockXhr() {
// hack for testing $http, $httpBackend
@@ -1633,8 +1619,8 @@ function MockXhr() {
/**
- * @ngdoc function
- * @name ngMock.$timeout
+ * @ngdoc service
+ * @name $timeout
* @description
*
* This service is just a simple decorator for {@link ng.$timeout $timeout} service
@@ -1645,8 +1631,7 @@ angular.mock.$TimeoutDecorator = function($delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$timeout#flush
- * @methodOf ngMock.$timeout
+ * @name $timeout#flush
* @description
*
* Flushes the queue of pending tasks.
@@ -1659,8 +1644,7 @@ angular.mock.$TimeoutDecorator = function($delegate, $browser) {
/**
* @ngdoc method
- * @name ngMock.$timeout#verifyNoPendingTasks
- * @methodOf ngMock.$timeout
+ * @name $timeout#verifyNoPendingTasks
* @description
*
* Verifies that there are no pending tasks that need to be flushed.
@@ -1684,6 +1668,48 @@ angular.mock.$TimeoutDecorator = function($delegate, $browser) {
return $delegate;
};
+angular.mock.$RAFDecorator = function($delegate) {
+ var queue = [];
+ var rafFn = function(fn) {
+ var index = queue.length;
+ queue.push(fn);
+ return function() {
+ queue.splice(index, 1);
+ };
+ };
+
+ rafFn.supported = $delegate.supported;
+
+ rafFn.flush = function() {
+ if(queue.length === 0) {
+ throw new Error('No rAF callbacks present');
+ }
+
+ var length = queue.length;
+ for(var i=0;i<length;i++) {
+ queue[i]();
+ }
+
+ queue = [];
+ };
+
+ return rafFn;
+};
+
+angular.mock.$AsyncCallbackDecorator = function($delegate) {
+ var callbacks = [];
+ var addFn = function(fn) {
+ callbacks.push(fn);
+ };
+ addFn.flush = function() {
+ angular.forEach(callbacks, function(fn) {
+ fn();
+ });
+ callbacks = [];
+ };
+ return addFn;
+};
+
/**
*
*/
@@ -1694,7 +1720,7 @@ angular.mock.$RootElementProvider = function() {
};
/**
- * @ngdoc overview
+ * @ngdoc module
* @name ngMock
* @description
*
@@ -1704,7 +1730,6 @@ angular.mock.$RootElementProvider = function() {
* In addition, ngMock also extends various core ng services such that they can be
* inspected and controlled in a synchronous manner within test code.
*
- * {@installModule mocks}
*
* <div doc-module-components="ngMock"></div>
*
@@ -1718,11 +1743,14 @@ angular.module('ngMock', ['ng']).provider({
$rootElement: angular.mock.$RootElementProvider
}).config(['$provide', function($provide) {
$provide.decorator('$timeout', angular.mock.$TimeoutDecorator);
+ $provide.decorator('$$rAF', angular.mock.$RAFDecorator);
+ $provide.decorator('$$asyncCallback', angular.mock.$AsyncCallbackDecorator);
}]);
/**
- * @ngdoc overview
+ * @ngdoc module
* @name ngMockE2E
+ * @module ngMockE2E
* @description
*
* The `ngMockE2E` is an angular module which contains mocks suitable for end-to-end testing.
@@ -1734,8 +1762,9 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
}]);
/**
- * @ngdoc object
- * @name ngMockE2E.$httpBackend
+ * @ngdoc service
+ * @name $httpBackend
+ * @module ngMockE2E
* @description
* Fake HTTP backend implementation suitable for end-to-end testing or backend-less development of
* applications that use the {@link ng.$http $http service}.
@@ -1761,7 +1790,7 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
* To setup the application to run with this http backend, you have to create a module that depends
* on the `ngMockE2E` and your application modules and defines the fake backend:
*
- * <pre>
+ * ```js
* myAppDev = angular.module('myAppDev', ['myApp', 'ngMockE2E']);
* myAppDev.run(function($httpBackend) {
* phones = [{name: 'phone1'}, {name: 'phone2'}];
@@ -1776,15 +1805,15 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
* $httpBackend.whenGET(/^\/templates\//).passThrough();
* //...
* });
- * </pre>
+ * ```
*
* Afterwards, bootstrap your app with this new module.
*/
/**
* @ngdoc method
- * @name ngMockE2E.$httpBackend#when
- * @methodOf ngMockE2E.$httpBackend
+ * @name $httpBackend#when
+ * @module ngMockE2E
* @description
* Creates a new backend definition.
*
@@ -1796,20 +1825,21 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
* control how a matched request is handled.
*
- * - respond –
- * `{function([status,] data[, headers])|function(function(method, url, data, headers)}`
- * – The respond method takes a set of static data to be returned or a function that can return
- * an array containing response status (number), response data (string) and response headers
- * (Object).
- * - passThrough – `{function()}` – Any request matching a backend definition with `passThrough`
- * handler, will be pass through to the real backend (an XHR request will be made to the
- * server.
+ * - respond –
+ * `{function([status,] data[, headers, statusText])
+ * | function(function(method, url, data, headers)}`
+ * – The respond method takes a set of static data to be returned or a function that can return
+ * an array containing response status (number), response data (string), response headers
+ * (Object), and the text for the status (string).
+ * - passThrough – `{function()}` – Any request matching a backend definition with
+ * `passThrough` handler will be passed through to the real backend (an XHR request will be made
+ * to the server.)
*/
/**
* @ngdoc method
- * @name ngMockE2E.$httpBackend#whenGET
- * @methodOf ngMockE2E.$httpBackend
+ * @name $httpBackend#whenGET
+ * @module ngMockE2E
* @description
* Creates a new backend definition for GET requests. For more info see `when()`.
*
@@ -1821,8 +1851,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
/**
* @ngdoc method
- * @name ngMockE2E.$httpBackend#whenHEAD
- * @methodOf ngMockE2E.$httpBackend
+ * @name $httpBackend#whenHEAD
+ * @module ngMockE2E
* @description
* Creates a new backend definition for HEAD requests. For more info see `when()`.
*
@@ -1834,8 +1864,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
/**
* @ngdoc method
- * @name ngMockE2E.$httpBackend#whenDELETE
- * @methodOf ngMockE2E.$httpBackend
+ * @name $httpBackend#whenDELETE
+ * @module ngMockE2E
* @description
* Creates a new backend definition for DELETE requests. For more info see `when()`.
*
@@ -1847,8 +1877,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
/**
* @ngdoc method
- * @name ngMockE2E.$httpBackend#whenPOST
- * @methodOf ngMockE2E.$httpBackend
+ * @name $httpBackend#whenPOST
+ * @module ngMockE2E
* @description
* Creates a new backend definition for POST requests. For more info see `when()`.
*
@@ -1861,8 +1891,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
/**
* @ngdoc method
- * @name ngMockE2E.$httpBackend#whenPUT
- * @methodOf ngMockE2E.$httpBackend
+ * @name $httpBackend#whenPUT
+ * @module ngMockE2E
* @description
* Creates a new backend definition for PUT requests. For more info see `when()`.
*
@@ -1875,8 +1905,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
/**
* @ngdoc method
- * @name ngMockE2E.$httpBackend#whenPATCH
- * @methodOf ngMockE2E.$httpBackend
+ * @name $httpBackend#whenPATCH
+ * @module ngMockE2E
* @description
* Creates a new backend definition for PATCH requests. For more info see `when()`.
*
@@ -1889,8 +1919,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
/**
* @ngdoc method
- * @name ngMockE2E.$httpBackend#whenJSONP
- * @methodOf ngMockE2E.$httpBackend
+ * @name $httpBackend#whenJSONP
+ * @module ngMockE2E
* @description
* Creates a new backend definition for JSONP requests. For more info see `when()`.
*
@@ -1918,10 +1948,13 @@ angular.mock.clearDataCache = function() {
};
+if(window.jasmine || window.mocha) {
-(window.jasmine || window.mocha) && (function(window) {
+ var currentSpec = null,
+ isSpecRunning = function() {
+ return !!currentSpec;
+ };
- var currentSpec = null;
beforeEach(function() {
currentSpec = this;
@@ -1954,10 +1987,6 @@ angular.mock.clearDataCache = function() {
angular.callbacks.counter = 0;
});
- function isSpecRunning() {
- return currentSpec && (window.mocha || currentSpec.queue.running);
- }
-
/**
* @ngdoc function
* @name angular.mock.module
@@ -2008,7 +2037,7 @@ angular.mock.clearDataCache = function() {
* *NOTE*: This function is also published on window for easy access.<br>
*
* The inject function wraps a function into an injectable function. The inject() creates new
- * instance of {@link AUTO.$injector $injector} per test, which is then used for
+ * instance of {@link auto.$injector $injector} per test, which is then used for
* resolving references.
*
*
@@ -2046,7 +2075,7 @@ angular.mock.clearDataCache = function() {
*
* ## Example
* Example of what a typical jasmine tests looks like with the inject method.
- * <pre>
+ * ```js
*
* angular.module('myApplicationModule', [])
* .value('mode', 'app')
@@ -2080,14 +2109,28 @@ angular.mock.clearDataCache = function() {
* });
* });
*
- * </pre>
+ * ```
*
* @param {...Function} fns any number of functions which will be injected using the injector.
*/
+
+
+
+ var ErrorAddingDeclarationLocationStack = function(e, errorForStack) {
+ this.message = e.message;
+ this.name = e.name;
+ if (e.line) this.line = e.line;
+ if (e.sourceId) this.sourceId = e.sourceId;
+ if (e.stack && errorForStack)
+ this.stack = e.stack + '\n' + errorForStack.stack;
+ if (e.stackArray) this.stackArray = e.stackArray;
+ };
+ ErrorAddingDeclarationLocationStack.prototype.toString = Error.prototype.toString;
+
window.inject = angular.mock.inject = function() {
var blockFns = Array.prototype.slice.call(arguments, 0);
var errorForStack = new Error('Declaration Location');
- return isSpecRunning() ? workFn() : workFn;
+ return isSpecRunning() ? workFn.call(currentSpec) : workFn;
/////////////////////
function workFn() {
var modules = currentSpec.$modules || [];
@@ -2104,7 +2147,9 @@ angular.mock.clearDataCache = function() {
injector.invoke(blockFns[i] || angular.noop, this);
/* jshint +W040 */
} catch (e) {
- if(e.stack && errorForStack) e.stack += '\n' + errorForStack.stack;
+ if (e.stack && errorForStack) {
+ throw new ErrorAddingDeclarationLocationStack(e, errorForStack);
+ }
throw e;
} finally {
errorForStack = null;
@@ -2112,4 +2157,7 @@ angular.mock.clearDataCache = function() {
}
}
};
-})(window); \ No newline at end of file
+}
+
+
+})(window, window.angular);