1
1
/**
2
- * @license AngularJS v1.3.7
2
+ * @license AngularJS v1.3.13
3
3
* (c) 2010-2014 Google, Inc. http://angularjs.org
4
4
* License: MIT
5
5
*/
@@ -250,31 +250,31 @@ angular.mock.$ExceptionHandlerProvider = function() {
250
250
*
251
251
* @param {string } mode Mode of operation, defaults to `rethrow`.
252
252
*
253
- * - `rethrow`: If any errors are passed to the handler in tests, it typically means that there
254
- * is a bug in the application or test, so this mock will make these tests fail.
255
253
* - `log`: Sometimes it is desirable to test that an error is thrown, for this case the `log`
256
254
* mode stores an array of errors in `$exceptionHandler.errors`, to allow later
257
255
* assertion of them. See {@link ngMock.$log#assertEmpty assertEmpty()} and
258
256
* {@link ngMock.$log#reset reset()}
257
+ * - `rethrow`: If any errors are passed to the handler in tests, it typically means that there
258
+ * is a bug in the application or test, so this mock will make these tests fail.
259
+ * For any implementations that expect exceptions to be thrown, the `rethrow` mode
260
+ * will also maintain a log of thrown errors.
259
261
*/
260
262
this . mode = function ( mode ) {
263
+
261
264
switch ( mode ) {
262
- case 'rethrow' :
263
- handler = function ( e ) {
264
- throw e ;
265
- } ;
266
- break ;
267
265
case 'log' :
266
+ case 'rethrow' :
268
267
var errors = [ ] ;
269
-
270
268
handler = function ( e ) {
271
269
if ( arguments . length == 1 ) {
272
270
errors . push ( e ) ;
273
271
} else {
274
272
errors . push ( [ ] . slice . call ( arguments , 0 ) ) ;
275
273
}
274
+ if ( mode === "rethrow" ) {
275
+ throw e ;
276
+ }
276
277
} ;
277
-
278
278
handler . errors = errors ;
279
279
break ;
280
280
default :
@@ -1283,7 +1283,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
1283
1283
* @param {string|RegExp|function(string) } url HTTP url or function that receives the url
1284
1284
* and returns true if the url match the current definition.
1285
1285
* @param {(Object|function(Object))= } headers HTTP headers.
1286
- * @returns {requestHandler } Returns an object with `respond` method that control how a matched
1286
+ * @returns {requestHandler } Returns an object with `respond` method that controls how a matched
1287
1287
* request is handled. You can save this object for later use and invoke `respond` again in
1288
1288
* order to change how a matched request is handled.
1289
1289
*/
@@ -1297,7 +1297,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
1297
1297
* @param {string|RegExp|function(string) } url HTTP url or function that receives the url
1298
1298
* and returns true if the url match the current definition.
1299
1299
* @param {(Object|function(Object))= } headers HTTP headers.
1300
- * @returns {requestHandler } Returns an object with `respond` method that control how a matched
1300
+ * @returns {requestHandler } Returns an object with `respond` method that controls how a matched
1301
1301
* request is handled. You can save this object for later use and invoke `respond` again in
1302
1302
* order to change how a matched request is handled.
1303
1303
*/
@@ -1311,7 +1311,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
1311
1311
* @param {string|RegExp|function(string) } url HTTP url or function that receives the url
1312
1312
* and returns true if the url match the current definition.
1313
1313
* @param {(Object|function(Object))= } headers HTTP headers.
1314
- * @returns {requestHandler } Returns an object with `respond` method that control how a matched
1314
+ * @returns {requestHandler } Returns an object with `respond` method that controls how a matched
1315
1315
* request is handled. You can save this object for later use and invoke `respond` again in
1316
1316
* order to change how a matched request is handled.
1317
1317
*/
@@ -1327,7 +1327,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
1327
1327
* @param {(string|RegExp|function(string))= } data HTTP request body or function that receives
1328
1328
* data string and returns true if the data is as expected.
1329
1329
* @param {(Object|function(Object))= } headers HTTP headers.
1330
- * @returns {requestHandler } Returns an object with `respond` method that control how a matched
1330
+ * @returns {requestHandler } Returns an object with `respond` method that controls how a matched
1331
1331
* request is handled. You can save this object for later use and invoke `respond` again in
1332
1332
* order to change how a matched request is handled.
1333
1333
*/
@@ -1343,7 +1343,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
1343
1343
* @param {(string|RegExp|function(string))= } data HTTP request body or function that receives
1344
1344
* data string and returns true if the data is as expected.
1345
1345
* @param {(Object|function(Object))= } headers HTTP headers.
1346
- * @returns {requestHandler } Returns an object with `respond` method that control how a matched
1346
+ * @returns {requestHandler } Returns an object with `respond` method that controls how a matched
1347
1347
* request is handled. You can save this object for later use and invoke `respond` again in
1348
1348
* order to change how a matched request is handled.
1349
1349
*/
@@ -1356,7 +1356,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
1356
1356
*
1357
1357
* @param {string|RegExp|function(string) } url HTTP url or function that receives the url
1358
1358
* and returns true if the url match the current definition.
1359
- * @returns {requestHandler } Returns an object with `respond` method that control how a matched
1359
+ * @returns {requestHandler } Returns an object with `respond` method that controls how a matched
1360
1360
* request is handled. You can save this object for later use and invoke `respond` again in
1361
1361
* order to change how a matched request is handled.
1362
1362
*/
@@ -1377,7 +1377,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
1377
1377
* is in JSON format.
1378
1378
* @param {(Object|function(Object))= } headers HTTP headers or function that receives http header
1379
1379
* object and returns true if the headers match the current expectation.
1380
- * @returns {requestHandler } Returns an object with `respond` method that control how a matched
1380
+ * @returns {requestHandler } Returns an object with `respond` method that controls how a matched
1381
1381
* request is handled. You can save this object for later use and invoke `respond` again in
1382
1382
* order to change how a matched request is handled.
1383
1383
*
@@ -1412,7 +1412,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
1412
1412
* @param {string|RegExp|function(string) } url HTTP url or function that receives the url
1413
1413
* and returns true if the url match the current definition.
1414
1414
* @param {Object= } headers HTTP headers.
1415
- * @returns {requestHandler } Returns an object with `respond` method that control how a matched
1415
+ * @returns {requestHandler } Returns an object with `respond` method that controls how a matched
1416
1416
* request is handled. You can save this object for later use and invoke `respond` again in
1417
1417
* order to change how a matched request is handled. See #expect for more info.
1418
1418
*/
@@ -1426,7 +1426,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
1426
1426
* @param {string|RegExp|function(string) } url HTTP url or function that receives the url
1427
1427
* and returns true if the url match the current definition.
1428
1428
* @param {Object= } headers HTTP headers.
1429
- * @returns {requestHandler } Returns an object with `respond` method that control how a matched
1429
+ * @returns {requestHandler } Returns an object with `respond` method that controls how a matched
1430
1430
* request is handled. You can save this object for later use and invoke `respond` again in
1431
1431
* order to change how a matched request is handled.
1432
1432
*/
@@ -1440,7 +1440,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
1440
1440
* @param {string|RegExp|function(string) } url HTTP url or function that receives the url
1441
1441
* and returns true if the url match the current definition.
1442
1442
* @param {Object= } headers HTTP headers.
1443
- * @returns {requestHandler } Returns an object with `respond` method that control how a matched
1443
+ * @returns {requestHandler } Returns an object with `respond` method that controls how a matched
1444
1444
* request is handled. You can save this object for later use and invoke `respond` again in
1445
1445
* order to change how a matched request is handled.
1446
1446
*/
@@ -1457,7 +1457,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
1457
1457
* receives data string and returns true if the data is as expected, or Object if request body
1458
1458
* is in JSON format.
1459
1459
* @param {Object= } headers HTTP headers.
1460
- * @returns {requestHandler } Returns an object with `respond` method that control how a matched
1460
+ * @returns {requestHandler } Returns an object with `respond` method that controls how a matched
1461
1461
* request is handled. You can save this object for later use and invoke `respond` again in
1462
1462
* order to change how a matched request is handled.
1463
1463
*/
@@ -1474,7 +1474,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
1474
1474
* receives data string and returns true if the data is as expected, or Object if request body
1475
1475
* is in JSON format.
1476
1476
* @param {Object= } headers HTTP headers.
1477
- * @returns {requestHandler } Returns an object with `respond` method that control how a matched
1477
+ * @returns {requestHandler } Returns an object with `respond` method that controls how a matched
1478
1478
* request is handled. You can save this object for later use and invoke `respond` again in
1479
1479
* order to change how a matched request is handled.
1480
1480
*/
@@ -1491,7 +1491,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
1491
1491
* receives data string and returns true if the data is as expected, or Object if request body
1492
1492
* is in JSON format.
1493
1493
* @param {Object= } headers HTTP headers.
1494
- * @returns {requestHandler } Returns an object with `respond` method that control how a matched
1494
+ * @returns {requestHandler } Returns an object with `respond` method that controls how a matched
1495
1495
* request is handled. You can save this object for later use and invoke `respond` again in
1496
1496
* order to change how a matched request is handled.
1497
1497
*/
@@ -1504,7 +1504,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
1504
1504
*
1505
1505
* @param {string|RegExp|function(string) } url HTTP url or function that receives the url
1506
1506
* and returns true if the url match the current definition.
1507
- * @returns {requestHandler } Returns an object with `respond` method that control how a matched
1507
+ * @returns {requestHandler } Returns an object with `respond` method that controls how a matched
1508
1508
* request is handled. You can save this object for later use and invoke `respond` again in
1509
1509
* order to change how a matched request is handled.
1510
1510
*/
@@ -2134,18 +2134,32 @@ angular.mock.$RootScopeDecorator = ['$delegate', function($delegate) {
2134
2134
if ( window . jasmine || window . mocha ) {
2135
2135
2136
2136
var currentSpec = null ,
2137
+ annotatedFunctions = [ ] ,
2137
2138
isSpecRunning = function ( ) {
2138
2139
return ! ! currentSpec ;
2139
2140
} ;
2140
2141
2142
+ angular . mock . $$annotate = angular . injector . $$annotate ;
2143
+ angular . injector . $$annotate = function ( fn ) {
2144
+ if ( typeof fn === 'function' && ! fn . $inject ) {
2145
+ annotatedFunctions . push ( fn ) ;
2146
+ }
2147
+ return angular . mock . $$annotate . apply ( this , arguments ) ;
2148
+ } ;
2149
+
2141
2150
2142
2151
( window . beforeEach || window . setup ) ( function ( ) {
2152
+ annotatedFunctions = [ ] ;
2143
2153
currentSpec = this ;
2144
2154
} ) ;
2145
2155
2146
2156
( window . afterEach || window . teardown ) ( function ( ) {
2147
2157
var injector = currentSpec . $injector ;
2148
2158
2159
+ annotatedFunctions . forEach ( function ( fn ) {
2160
+ delete fn . $inject ;
2161
+ } ) ;
2162
+
2149
2163
angular . forEach ( currentSpec . $modules , function ( module ) {
2150
2164
if ( module && module . $$hashKey ) {
2151
2165
module . $$hashKey = undefined ;
0 commit comments