|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
/**
|
|
|
|
|
* @license AngularJS v1.3.7
|
|
|
|
|
* @license AngularJS v1.3.13
|
|
|
|
|
* (c) 2010-2014 Google, Inc. http://angularjs.org
|
|
|
|
|
* License: MIT
|
|
|
|
|
*/
|
|
|
|
@ -250,31 +250,31 @@ angular.mock.$ExceptionHandlerProvider = function() {
|
|
|
|
|
*
|
|
|
|
|
* @param {string} mode Mode of operation, defaults to `rethrow`.
|
|
|
|
|
*
|
|
|
|
|
* - `rethrow`: If any errors are passed to the handler in tests, it typically means that there
|
|
|
|
|
* is a bug in the application or test, so this mock will make these tests fail.
|
|
|
|
|
* - `log`: Sometimes it is desirable to test that an error is thrown, for this case the `log`
|
|
|
|
|
* mode stores an array of errors in `$exceptionHandler.errors`, to allow later
|
|
|
|
|
* assertion of them. See {@link ngMock.$log#assertEmpty assertEmpty()} and
|
|
|
|
|
* {@link ngMock.$log#reset reset()}
|
|
|
|
|
* - `rethrow`: If any errors are passed to the handler in tests, it typically means that there
|
|
|
|
|
* is a bug in the application or test, so this mock will make these tests fail.
|
|
|
|
|
* For any implementations that expect exceptions to be thrown, the `rethrow` mode
|
|
|
|
|
* will also maintain a log of thrown errors.
|
|
|
|
|
*/
|
|
|
|
|
this.mode = function(mode) {
|
|
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
|
case 'rethrow':
|
|
|
|
|
handler = function(e) {
|
|
|
|
|
throw e;
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case 'log':
|
|
|
|
|
case 'rethrow':
|
|
|
|
|
var errors = [];
|
|
|
|
|
|
|
|
|
|
handler = function(e) {
|
|
|
|
|
if (arguments.length == 1) {
|
|
|
|
|
errors.push(e);
|
|
|
|
|
} else {
|
|
|
|
|
errors.push([].slice.call(arguments, 0));
|
|
|
|
|
}
|
|
|
|
|
if (mode === "rethrow") {
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
handler.errors = errors;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
@ -1283,7 +1283,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
|
|
|
|
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
|
|
|
|
* and returns true if the url match the current definition.
|
|
|
|
|
* @param {(Object|function(Object))=} headers HTTP headers.
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
|
|
|
|
|
* request is handled. You can save this object for later use and invoke `respond` again in
|
|
|
|
|
* order to change how a matched request is handled.
|
|
|
|
|
*/
|
|
|
|
@ -1297,7 +1297,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
|
|
|
|
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
|
|
|
|
* and returns true if the url match the current definition.
|
|
|
|
|
* @param {(Object|function(Object))=} headers HTTP headers.
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
|
|
|
|
|
* request is handled. You can save this object for later use and invoke `respond` again in
|
|
|
|
|
* order to change how a matched request is handled.
|
|
|
|
|
*/
|
|
|
|
@ -1311,7 +1311,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
|
|
|
|
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
|
|
|
|
* and returns true if the url match the current definition.
|
|
|
|
|
* @param {(Object|function(Object))=} headers HTTP headers.
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
|
|
|
|
|
* request is handled. You can save this object for later use and invoke `respond` again in
|
|
|
|
|
* order to change how a matched request is handled.
|
|
|
|
|
*/
|
|
|
|
@ -1327,7 +1327,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
|
|
|
|
* @param {(string|RegExp|function(string))=} data HTTP request body or function that receives
|
|
|
|
|
* data string and returns true if the data is as expected.
|
|
|
|
|
* @param {(Object|function(Object))=} headers HTTP headers.
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
|
|
|
|
|
* request is handled. You can save this object for later use and invoke `respond` again in
|
|
|
|
|
* order to change how a matched request is handled.
|
|
|
|
|
*/
|
|
|
|
@ -1343,7 +1343,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
|
|
|
|
* @param {(string|RegExp|function(string))=} data HTTP request body or function that receives
|
|
|
|
|
* data string and returns true if the data is as expected.
|
|
|
|
|
* @param {(Object|function(Object))=} headers HTTP headers.
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
|
|
|
|
|
* request is handled. You can save this object for later use and invoke `respond` again in
|
|
|
|
|
* order to change how a matched request is handled.
|
|
|
|
|
*/
|
|
|
|
@ -1356,7 +1356,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
|
|
|
|
*
|
|
|
|
|
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
|
|
|
|
* and returns true if the url match the current definition.
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
|
|
|
|
|
* request is handled. You can save this object for later use and invoke `respond` again in
|
|
|
|
|
* order to change how a matched request is handled.
|
|
|
|
|
*/
|
|
|
|
@ -1377,7 +1377,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
|
|
|
|
* is in JSON format.
|
|
|
|
|
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
|
|
|
|
|
* object and returns true if the headers match the current expectation.
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
|
|
|
|
|
* request is handled. You can save this object for later use and invoke `respond` again in
|
|
|
|
|
* order to change how a matched request is handled.
|
|
|
|
|
*
|
|
|
|
@ -1412,7 +1412,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
|
|
|
|
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
|
|
|
|
* and returns true if the url match the current definition.
|
|
|
|
|
* @param {Object=} headers HTTP headers.
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
|
|
|
|
|
* request is handled. You can save this object for later use and invoke `respond` again in
|
|
|
|
|
* order to change how a matched request is handled. See #expect for more info.
|
|
|
|
|
*/
|
|
|
|
@ -1426,7 +1426,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
|
|
|
|
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
|
|
|
|
* and returns true if the url match the current definition.
|
|
|
|
|
* @param {Object=} headers HTTP headers.
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
|
|
|
|
|
* request is handled. You can save this object for later use and invoke `respond` again in
|
|
|
|
|
* order to change how a matched request is handled.
|
|
|
|
|
*/
|
|
|
|
@ -1440,7 +1440,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
|
|
|
|
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
|
|
|
|
* and returns true if the url match the current definition.
|
|
|
|
|
* @param {Object=} headers HTTP headers.
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
|
|
|
|
|
* request is handled. You can save this object for later use and invoke `respond` again in
|
|
|
|
|
* order to change how a matched request is handled.
|
|
|
|
|
*/
|
|
|
|
@ -1457,7 +1457,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
|
|
|
|
* receives data string and returns true if the data is as expected, or Object if request body
|
|
|
|
|
* is in JSON format.
|
|
|
|
|
* @param {Object=} headers HTTP headers.
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
|
|
|
|
|
* request is handled. You can save this object for later use and invoke `respond` again in
|
|
|
|
|
* order to change how a matched request is handled.
|
|
|
|
|
*/
|
|
|
|
@ -1474,7 +1474,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
|
|
|
|
* receives data string and returns true if the data is as expected, or Object if request body
|
|
|
|
|
* is in JSON format.
|
|
|
|
|
* @param {Object=} headers HTTP headers.
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
|
|
|
|
|
* request is handled. You can save this object for later use and invoke `respond` again in
|
|
|
|
|
* order to change how a matched request is handled.
|
|
|
|
|
*/
|
|
|
|
@ -1491,7 +1491,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
|
|
|
|
* receives data string and returns true if the data is as expected, or Object if request body
|
|
|
|
|
* is in JSON format.
|
|
|
|
|
* @param {Object=} headers HTTP headers.
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
|
|
|
|
|
* request is handled. You can save this object for later use and invoke `respond` again in
|
|
|
|
|
* order to change how a matched request is handled.
|
|
|
|
|
*/
|
|
|
|
@ -1504,7 +1504,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
|
|
|
|
*
|
|
|
|
|
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
|
|
|
|
* and returns true if the url match the current definition.
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
|
|
|
|
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
|
|
|
|
|
* request is handled. You can save this object for later use and invoke `respond` again in
|
|
|
|
|
* order to change how a matched request is handled.
|
|
|
|
|
*/
|
|
|
|
@ -2134,18 +2134,32 @@ angular.mock.$RootScopeDecorator = ['$delegate', function($delegate) {
|
|
|
|
|
if (window.jasmine || window.mocha) {
|
|
|
|
|
|
|
|
|
|
var currentSpec = null,
|
|
|
|
|
annotatedFunctions = [],
|
|
|
|
|
isSpecRunning = function() {
|
|
|
|
|
return !!currentSpec;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
angular.mock.$$annotate = angular.injector.$$annotate;
|
|
|
|
|
angular.injector.$$annotate = function(fn) {
|
|
|
|
|
if (typeof fn === 'function' && !fn.$inject) {
|
|
|
|
|
annotatedFunctions.push(fn);
|
|
|
|
|
}
|
|
|
|
|
return angular.mock.$$annotate.apply(this, arguments);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(window.beforeEach || window.setup)(function() {
|
|
|
|
|
annotatedFunctions = [];
|
|
|
|
|
currentSpec = this;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
(window.afterEach || window.teardown)(function() {
|
|
|
|
|
var injector = currentSpec.$injector;
|
|
|
|
|
|
|
|
|
|
annotatedFunctions.forEach(function(fn) {
|
|
|
|
|
delete fn.$inject;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
angular.forEach(currentSpec.$modules, function(module) {
|
|
|
|
|
if (module && module.$$hashKey) {
|
|
|
|
|
module.$$hashKey = undefined;
|
|
|
|
|