angularjs-rails 1.2.0.rc3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license AngularJS v1.2.0-rc.3
2
+ * @license AngularJS v1.2.0
3
3
  * (c) 2010-2012 Google, Inc. http://angularjs.org
4
4
  * License: MIT
5
5
  */
@@ -12,11 +12,12 @@
12
12
  *
13
13
  * # ngCookies
14
14
  *
15
- * Provides the {@link ngCookies.$cookies `$cookies`} and
16
- * {@link ngCookies.$cookieStore `$cookieStore`} services.
15
+ * The `ngCookies` module provides a convenient wrapper for reading and writing browser cookies.
17
16
  *
18
17
  * {@installModule cookies}
19
18
  *
19
+ * <div doc-module-components="ngCookies"></div>
20
+ *
20
21
  * See {@link ngCookies.$cookies `$cookies`} and
21
22
  * {@link ngCookies.$cookieStore `$cookieStore`} for usage.
22
23
  */
@@ -80,7 +81,8 @@ angular.module('ngCookies', ['ng']).
80
81
 
81
82
 
82
83
  /**
83
- * Pushes all the cookies from the service to the browser and verifies if all cookies were stored.
84
+ * Pushes all the cookies from the service to the browser and verifies if all cookies were
85
+ * stored.
84
86
  */
85
87
  function push() {
86
88
  var name,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license AngularJS v1.2.0-rc.3
2
+ * @license AngularJS v1.2.0
3
3
  * (c) 2010-2012 Google, Inc. http://angularjs.org
4
4
  * License: MIT
5
5
  */
@@ -31,7 +31,8 @@ function setupModuleLoader(window) {
31
31
  * @name angular.module
32
32
  * @description
33
33
  *
34
- * The `angular.module` is a global place for creating, registering and retrieving Angular modules.
34
+ * The `angular.module` is a global place for creating, registering and retrieving Angular
35
+ * modules.
35
36
  * All modules (angular core or 3rd party) that should be available to an application must be
36
37
  * registered using this mechanism.
37
38
  *
@@ -69,10 +70,10 @@ function setupModuleLoader(window) {
69
70
  * {@link angular.bootstrap} to simplify this process for you.
70
71
  *
71
72
  * @param {!string} name The name of the module to create or retrieve.
72
- * @param {Array.<string>=} requires If specified then new module is being created. If unspecified then the
73
- * the module is being retrieved for further configuration.
73
+ * @param {Array.<string>=} requires If specified then new module is being created. If
74
+ * unspecified then the the module is being retrieved for further configuration.
74
75
  * @param {Function} configFn Optional configuration function for the module. Same as
75
- * {@link angular.Module#config Module#config()}.
76
+ * {@link angular.Module#methods_config Module#config()}.
76
77
  * @returns {module} new module with the {@link angular.Module} api.
77
78
  */
78
79
  return function module(name, requires, configFn) {
@@ -82,9 +83,9 @@ function setupModuleLoader(window) {
82
83
  }
83
84
  return ensure(modules, name, function() {
84
85
  if (!requires) {
85
- throw $injectorMinErr('nomod', "Module '{0}' is not available! You either misspelled the module name " +
86
- "or forgot to load it. If registering a module ensure that you specify the dependencies as the second " +
87
- "argument.", name);
86
+ throw $injectorMinErr('nomod', "Module '{0}' is not available! You either misspelled " +
87
+ "the module name or forgot to load it. If registering a module ensure that you " +
88
+ "specify the dependencies as the second argument.", name);
88
89
  }
89
90
 
90
91
  /** @type {!Array.<Array.<*>>} */
@@ -107,7 +108,8 @@ function setupModuleLoader(window) {
107
108
  * @propertyOf angular.Module
108
109
  * @returns {Array.<string>} List of module names which must be loaded before this module.
109
110
  * @description
110
- * Holds the list of modules which the injector will load before the current module is loaded.
111
+ * Holds the list of modules which the injector will load before the current module is
112
+ * loaded.
111
113
  */
112
114
  requires: requires,
113
115
 
@@ -126,7 +128,8 @@ function setupModuleLoader(window) {
126
128
  * @name angular.Module#provider
127
129
  * @methodOf angular.Module
128
130
  * @param {string} name service name
129
- * @param {Function} providerType Construction function for creating new instance of the service.
131
+ * @param {Function} providerType Construction function for creating new instance of the
132
+ * service.
130
133
  * @description
131
134
  * See {@link AUTO.$provide#provider $provide.provider()}.
132
135
  */
@@ -182,14 +185,15 @@ function setupModuleLoader(window) {
182
185
  * @name angular.Module#animation
183
186
  * @methodOf angular.Module
184
187
  * @param {string} name animation name
185
- * @param {Function} animationFactory Factory function for creating new instance of an animation.
188
+ * @param {Function} animationFactory Factory function for creating new instance of an
189
+ * animation.
186
190
  * @description
187
191
  *
188
192
  * **NOTE**: animations take effect only if the **ngAnimate** module is loaded.
189
193
  *
190
194
  *
191
- * Defines an animation hook that can be later used with {@link ngAnimate.$animate $animate} service and
192
- * directives that use this service.
195
+ * Defines an animation hook that can be later used with
196
+ * {@link ngAnimate.$animate $animate} service and directives that use this service.
193
197
  *
194
198
  * <pre>
195
199
  * module.animation('.animation-name', function($inject1, $inject2) {
@@ -242,7 +246,7 @@ function setupModuleLoader(window) {
242
246
  * @param {Function} directiveFactory Factory function for creating new instance of
243
247
  * directives.
244
248
  * @description
245
- * See {@link ng.$compileProvider#directive $compileProvider.directive()}.
249
+ * See {@link ng.$compileProvider#methods_directive $compileProvider.directive()}.
246
250
  */
247
251
  directive: invokeLater('$compileProvider', 'directive'),
248
252
 
@@ -289,7 +293,7 @@ function setupModuleLoader(window) {
289
293
  return function() {
290
294
  invokeQueue[insertMethod || 'push']([provider, method, arguments]);
291
295
  return moduleInstance;
292
- }
296
+ };
293
297
  }
294
298
  });
295
299
  };
@@ -1,5 +1,7 @@
1
+ 'use strict';
2
+
1
3
  /**
2
- * @license AngularJS v1.2.0-rc.3
4
+ * @license AngularJS v1.2.0
3
5
  * (c) 2010-2012 Google, Inc. http://angularjs.org
4
6
  * License: MIT
5
7
  *
@@ -117,7 +119,7 @@ angular.mock.$Browser = function() {
117
119
  if (self.deferredFns.length) {
118
120
  self.defer.now = self.deferredFns[self.deferredFns.length-1].time;
119
121
  } else {
120
- throw Error('No deferred tasks to be flushed');
122
+ throw new Error('No deferred tasks to be flushed');
121
123
  }
122
124
  }
123
125
 
@@ -162,7 +164,7 @@ angular.mock.$Browser.prototype = {
162
164
 
163
165
  cookies: function(name, value) {
164
166
  if (name) {
165
- if (value == undefined) {
167
+ if (angular.isUndefined(value)) {
166
168
  delete this.cookieHash[name];
167
169
  } else {
168
170
  if (angular.isString(value) && //strings only
@@ -190,8 +192,8 @@ angular.mock.$Browser.prototype = {
190
192
  * @name ngMock.$exceptionHandlerProvider
191
193
  *
192
194
  * @description
193
- * Configures the mock implementation of {@link ng.$exceptionHandler} to rethrow or to log errors passed
194
- * into the `$exceptionHandler`.
195
+ * Configures the mock implementation of {@link ng.$exceptionHandler} to rethrow or to log errors
196
+ * passed into the `$exceptionHandler`.
195
197
  */
196
198
 
197
199
  /**
@@ -244,10 +246,10 @@ angular.mock.$ExceptionHandlerProvider = function() {
244
246
  * - `rethrow`: If any errors are passed into the handler in tests, it typically
245
247
  * means that there is a bug in the application or test, so this mock will
246
248
  * make these tests fail.
247
- * - `log`: Sometimes it is desirable to test that an error is thrown, for this case the `log` mode stores an
248
- * array of errors in `$exceptionHandler.errors`, to allow later assertion of them.
249
- * See {@link ngMock.$log#assertEmpty assertEmpty()} and
250
- * {@link ngMock.$log#reset reset()}
249
+ * - `log`: Sometimes it is desirable to test that an error is thrown, for this case the `log`
250
+ * mode stores an array of errors in `$exceptionHandler.errors`, to allow later
251
+ * assertion of them. See {@link ngMock.$log#assertEmpty assertEmpty()} and
252
+ * {@link ngMock.$log#reset reset()}
251
253
  */
252
254
  this.mode = function(mode) {
253
255
  switch(mode) {
@@ -270,7 +272,7 @@ angular.mock.$ExceptionHandlerProvider = function() {
270
272
  handler.errors = errors;
271
273
  break;
272
274
  default:
273
- throw Error("Unknown mode '" + mode + "', only 'log'/'rethrow' modes are allowed!");
275
+ throw new Error("Unknown mode '" + mode + "', only 'log'/'rethrow' modes are allowed!");
274
276
  }
275
277
  };
276
278
 
@@ -300,12 +302,12 @@ angular.mock.$LogProvider = function() {
300
302
  }
301
303
 
302
304
  this.debugEnabled = function(flag) {
303
- if (angular.isDefined(flag)) {
304
- debug = flag;
305
- return this;
306
- } else {
307
- return debug;
308
- }
305
+ if (angular.isDefined(flag)) {
306
+ debug = flag;
307
+ return this;
308
+ } else {
309
+ return debug;
310
+ }
309
311
  };
310
312
 
311
313
  this.$get = function () {
@@ -404,7 +406,7 @@ angular.mock.$LogProvider = function() {
404
406
  * var first = $log.debug.logs.unshift();
405
407
  * </pre>
406
408
  */
407
- $log.debug.logs = []
409
+ $log.debug.logs = [];
408
410
  };
409
411
 
410
412
  /**
@@ -413,20 +415,22 @@ angular.mock.$LogProvider = function() {
413
415
  * @methodOf ngMock.$log
414
416
  *
415
417
  * @description
416
- * Assert that the all of the logging methods have no logged messages. If messages present, an exception is thrown.
418
+ * Assert that the all of the logging methods have no logged messages. If messages present, an
419
+ * exception is thrown.
417
420
  */
418
421
  $log.assertEmpty = function() {
419
422
  var errors = [];
420
423
  angular.forEach(['error', 'warn', 'info', 'log', 'debug'], function(logLevel) {
421
424
  angular.forEach($log[logLevel].logs, function(log) {
422
425
  angular.forEach(log, function (logItem) {
423
- errors.push('MOCK $log (' + logLevel + '): ' + String(logItem) + '\n' + (logItem.stack || ''));
426
+ errors.push('MOCK $log (' + logLevel + '): ' + String(logItem) + '\n' +
427
+ (logItem.stack || ''));
424
428
  });
425
429
  });
426
430
  });
427
431
  if (errors.length) {
428
- errors.unshift("Expected $log to be empty! Either a message was logged unexpectedly, or an expected " +
429
- "log message was not checked and removed:");
432
+ errors.unshift("Expected $log to be empty! Either a message was logged unexpectedly, or "+
433
+ "an expected log message was not checked and removed:");
430
434
  errors.push('');
431
435
  throw new Error(errors.join('\n---------\n'));
432
436
  }
@@ -445,7 +449,7 @@ angular.mock.$LogProvider = function() {
445
449
  * @description
446
450
  * Mock implementation of the $interval service.
447
451
  *
448
- * Use {@link ngMock.$interval#flush `$interval.flush(millis)`} to
452
+ * Use {@link ngMock.$interval#methods_flush `$interval.flush(millis)`} to
449
453
  * move forward by `millis` milliseconds and trigger any functions scheduled to run in that
450
454
  * time.
451
455
  *
@@ -454,7 +458,7 @@ angular.mock.$LogProvider = function() {
454
458
  * @param {number=} [count=0] Number of times to repeat. If not set, or 0, will repeat
455
459
  * indefinitely.
456
460
  * @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise
457
- * will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block.
461
+ * will invoke `fn` within the {@link ng.$rootScope.Scope#methods_$apply $apply} block.
458
462
  * @returns {promise} A promise which will be notified on each iteration.
459
463
  */
460
464
  angular.mock.$IntervalProvider = function() {
@@ -467,10 +471,10 @@ angular.mock.$IntervalProvider = function() {
467
471
  var $interval = function(fn, delay, count, invokeApply) {
468
472
  var deferred = $q.defer(),
469
473
  promise = deferred.promise,
470
- count = (angular.isDefined(count)) ? count : 0,
471
474
  iteration = 0,
472
475
  skipApply = (angular.isDefined(invokeApply) && !invokeApply);
473
476
 
477
+ count = (angular.isDefined(count)) ? count : 0,
474
478
  promise.then(null, null, fn);
475
479
 
476
480
  promise.$$intervalId = nextRepeatId;
@@ -492,7 +496,7 @@ angular.mock.$IntervalProvider = function() {
492
496
  }
493
497
 
494
498
  if (!skipApply) $rootScope.$apply();
495
- };
499
+ }
496
500
 
497
501
  repeatFns.push({
498
502
  nextTime:(now + delay),
@@ -551,6 +555,11 @@ angular.mock.$IntervalProvider = function() {
551
555
  };
552
556
 
553
557
 
558
+ /* jshint -W101 */
559
+ /* The R_ISO8061_STR regex is never going to fit into the 100 char limit!
560
+ * This directive should go inside the anonymous function but a bug in JSHint means that it would
561
+ * not be enacted early enough to prevent the warning.
562
+ */
554
563
  (function() {
555
564
  var R_ISO8061_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?:\:?(\d\d)(?:\:?(\d\d)(?:\.(\d{3}))?)?)?(Z|([+-])(\d\d):?(\d\d)))?$/;
556
565
 
@@ -565,7 +574,10 @@ angular.mock.$IntervalProvider = function() {
565
574
  tzMin = int(match[9] + match[11]);
566
575
  }
567
576
  date.setUTCFullYear(int(match[1]), int(match[2]) - 1, int(match[3]));
568
- date.setUTCHours(int(match[4]||0) - tzHour, int(match[5]||0) - tzMin, int(match[6]||0), int(match[7]||0));
577
+ date.setUTCHours(int(match[4]||0) - tzHour,
578
+ int(match[5]||0) - tzMin,
579
+ int(match[6]||0),
580
+ int(match[7]||0));
569
581
  return date;
570
582
  }
571
583
  return string;
@@ -728,8 +740,8 @@ angular.mock.$IntervalProvider = function() {
728
740
  padNumber(self.origDate.getUTCHours(), 2) + ':' +
729
741
  padNumber(self.origDate.getUTCMinutes(), 2) + ':' +
730
742
  padNumber(self.origDate.getUTCSeconds(), 2) + '.' +
731
- padNumber(self.origDate.getUTCMilliseconds(), 3) + 'Z'
732
- }
743
+ padNumber(self.origDate.getUTCMilliseconds(), 3) + 'Z';
744
+ };
733
745
  }
734
746
 
735
747
  //hide all methods not implemented in this mock that the Date prototype exposes
@@ -742,7 +754,7 @@ angular.mock.$IntervalProvider = function() {
742
754
 
743
755
  angular.forEach(unimplementedMethods, function(methodName) {
744
756
  self[methodName] = function() {
745
- throw Error("Method '" + methodName + "' is not implemented in the TzDate mock");
757
+ throw new Error("Method '" + methodName + "' is not implemented in the TzDate mock");
746
758
  };
747
759
  });
748
760
 
@@ -752,6 +764,7 @@ angular.mock.$IntervalProvider = function() {
752
764
  //make "tzDateInstance instanceof Date" return true
753
765
  angular.mock.TzDate.prototype = Date.prototype;
754
766
  })();
767
+ /* jshint +W101 */
755
768
 
756
769
  angular.mock.animate = angular.module('mock.animate', ['ng'])
757
770
 
@@ -763,7 +776,12 @@ angular.mock.animate = angular.module('mock.animate', ['ng'])
763
776
  enabled : $delegate.enabled,
764
777
  flushNext : function(name) {
765
778
  var tick = animate.queue.shift();
766
- expect(tick.method).toBe(name);
779
+
780
+ if (!tick) throw new Error('No animation to be flushed');
781
+ if(tick.method !== name) {
782
+ throw new Error('The next animation is not "' + name +
783
+ '", but is "' + tick.method + '"');
784
+ }
767
785
  tick.fn();
768
786
  return tick;
769
787
  }
@@ -798,9 +816,11 @@ angular.mock.animate = angular.module('mock.animate', ['ng'])
798
816
  *
799
817
  * *NOTE*: this is not an injectable instance, just a globally available function.
800
818
  *
801
- * Method for serializing common angular objects (scope, elements, etc..) into strings, useful for debugging.
819
+ * Method for serializing common angular objects (scope, elements, etc..) into strings, useful for
820
+ * debugging.
802
821
  *
803
- * This method is also available on window, where it can be used to display objects on debug console.
822
+ * This method is also available on window, where it can be used to display objects on debug
823
+ * console.
804
824
  *
805
825
  * @param {*} object - any object to turn into string.
806
826
  * @return {string} a serialized string of the argument
@@ -830,7 +850,8 @@ angular.mock.dump = function(object) {
830
850
  } else if (object instanceof Error) {
831
851
  out = object.stack || ('' + object.name + ': ' + object.message);
832
852
  } else {
833
- // TODO(i): this prevents methods to be logged, we should have a better way to serialize objects
853
+ // TODO(i): this prevents methods being logged,
854
+ // we should have a better way to serialize objects
834
855
  out = angular.toJson(object, true);
835
856
  }
836
857
  } else {
@@ -1129,7 +1150,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
1129
1150
 
1130
1151
  if (!expectation.matchHeaders(headers))
1131
1152
  throw new Error('Expected ' + expectation + ' with different headers\n' +
1132
- 'EXPECTED: ' + prettyPrint(expectation.headers) + '\nGOT: ' + prettyPrint(headers));
1153
+ 'EXPECTED: ' + prettyPrint(expectation.headers) + '\nGOT: ' +
1154
+ prettyPrint(headers));
1133
1155
 
1134
1156
  expectations.shift();
1135
1157
 
@@ -1148,7 +1170,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
1148
1170
  ($browser ? $browser.defer : responsesPush)(wrapResponse(definition));
1149
1171
  } else if (definition.passThrough) {
1150
1172
  $delegate(method, url, data, callback, headers, timeout, withCredentials);
1151
- } else throw Error('No response defined !');
1173
+ } else throw new Error('No response defined !');
1152
1174
  return;
1153
1175
  }
1154
1176
  }
@@ -1171,10 +1193,11 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
1171
1193
  * data string and returns true if the data is as expected.
1172
1194
  * @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
1173
1195
  * object and returns true if the headers match the current definition.
1174
- * @returns {requestHandler} Returns an object with `respond` method that control how a matched
1196
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
1175
1197
  * request is handled.
1176
1198
  *
1177
- * - respond – `{function([status,] data[, headers])|function(function(method, url, data, headers)}`
1199
+ * - respond –
1200
+ * `{function([status,] data[, headers])|function(function(method, url, data, headers)}`
1178
1201
  * – The respond method takes a set of static data to be returned or a function that can return
1179
1202
  * an array containing response status (number), response data (string) and response headers
1180
1203
  * (Object).
@@ -1297,7 +1320,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
1297
1320
  * @returns {requestHandler} Returns an object with `respond` method that control how a matched
1298
1321
  * request is handled.
1299
1322
  *
1300
- * - respond – `{function([status,] data[, headers])|function(function(method, url, data, headers)}`
1323
+ * - respond –
1324
+ * `{function([status,] data[, headers])|function(function(method, url, data, headers)}`
1301
1325
  * – The respond method takes a set of static data to be returned or a function that can return
1302
1326
  * an array containing response status (number), response data (string) and response headers
1303
1327
  * (Object).
@@ -1427,11 +1451,11 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
1427
1451
  */
1428
1452
  $httpBackend.flush = function(count) {
1429
1453
  $rootScope.$digest();
1430
- if (!responses.length) throw Error('No pending request to flush !');
1454
+ if (!responses.length) throw new Error('No pending request to flush !');
1431
1455
 
1432
1456
  if (angular.isDefined(count)) {
1433
1457
  while (count--) {
1434
- if (!responses.length) throw Error('No more pending request to flush !');
1458
+ if (!responses.length) throw new Error('No more pending request to flush !');
1435
1459
  responses.shift()();
1436
1460
  }
1437
1461
  } else {
@@ -1482,7 +1506,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
1482
1506
  */
1483
1507
  $httpBackend.verifyNoOutstandingRequest = function() {
1484
1508
  if (responses.length) {
1485
- throw Error('Unflushed requests: ' + responses.length);
1509
+ throw new Error('Unflushed requests: ' + responses.length);
1486
1510
  }
1487
1511
  };
1488
1512
 
@@ -1507,14 +1531,14 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
1507
1531
  function createShortMethods(prefix) {
1508
1532
  angular.forEach(['GET', 'DELETE', 'JSONP'], function(method) {
1509
1533
  $httpBackend[prefix + method] = function(url, headers) {
1510
- return $httpBackend[prefix](method, url, undefined, headers)
1511
- }
1534
+ return $httpBackend[prefix](method, url, undefined, headers);
1535
+ };
1512
1536
  });
1513
1537
 
1514
1538
  angular.forEach(['PUT', 'POST', 'PATCH'], function(method) {
1515
1539
  $httpBackend[prefix + method] = function(url, data, headers) {
1516
- return $httpBackend[prefix](method, url, data, headers)
1517
- }
1540
+ return $httpBackend[prefix](method, url, data, headers);
1541
+ };
1518
1542
  });
1519
1543
  }
1520
1544
  }
@@ -1579,7 +1603,8 @@ function MockXhr() {
1579
1603
  };
1580
1604
 
1581
1605
  this.getResponseHeader = function(name) {
1582
- // the lookup must be case insensitive, that's why we try two quick lookups and full scan at last
1606
+ // the lookup must be case insensitive,
1607
+ // that's why we try two quick lookups first and full scan last
1583
1608
  var header = this.$$respHeaders[name];
1584
1609
  if (header) return header;
1585
1610
 
@@ -1640,7 +1665,8 @@ angular.mock.$TimeoutDecorator = function($delegate, $browser) {
1640
1665
  *
1641
1666
  * Flushes the next timeout in the queue and compares it to the provided delay
1642
1667
  *
1643
- * @param {number=} expectedDelay the delay value that will be asserted against the delay of the next timeout function
1668
+ * @param {number=} expectedDelay the delay value that will be asserted against the delay of the
1669
+ * next timeout function
1644
1670
  */
1645
1671
  $delegate.flushNext = function(expectedDelay) {
1646
1672
  $browser.defer.flushNext(expectedDelay);
@@ -1679,7 +1705,7 @@ angular.mock.$TimeoutDecorator = function($delegate, $browser) {
1679
1705
  angular.mock.$RootElementProvider = function() {
1680
1706
  this.$get = function() {
1681
1707
  return angular.element('<div ng-app></div>');
1682
- }
1708
+ };
1683
1709
  };
1684
1710
 
1685
1711
  /**
@@ -1687,8 +1713,16 @@ angular.mock.$RootElementProvider = function() {
1687
1713
  * @name ngMock
1688
1714
  * @description
1689
1715
  *
1690
- * The `ngMock` is an angular module which is used with `ng` module and adds unit-test configuration as well as useful
1691
- * mocks to the {@link AUTO.$injector $injector}.
1716
+ * # ngMock
1717
+ *
1718
+ * The `ngMock` module providers support to inject and mock Angular services into unit tests.
1719
+ * In addition, ngMock also extends various core ng services such that they can be
1720
+ * inspected and controlled in a synchronous manner within test code.
1721
+ *
1722
+ * {@installModule mocks}
1723
+ *
1724
+ * <div doc-module-components="ngMock"></div>
1725
+ *
1692
1726
  */
1693
1727
  angular.module('ngMock', ['ng']).provider({
1694
1728
  $browser: angular.mock.$BrowserProvider,
@@ -1697,9 +1731,9 @@ angular.module('ngMock', ['ng']).provider({
1697
1731
  $interval: angular.mock.$IntervalProvider,
1698
1732
  $httpBackend: angular.mock.$HttpBackendProvider,
1699
1733
  $rootElement: angular.mock.$RootElementProvider
1700
- }).config(function($provide) {
1734
+ }).config(['$provide', function($provide) {
1701
1735
  $provide.decorator('$timeout', angular.mock.$TimeoutDecorator);
1702
- });
1736
+ }]);
1703
1737
 
1704
1738
  /**
1705
1739
  * @ngdoc overview
@@ -1710,9 +1744,9 @@ angular.module('ngMock', ['ng']).provider({
1710
1744
  * Currently there is only one mock present in this module -
1711
1745
  * the {@link ngMockE2E.$httpBackend e2e $httpBackend} mock.
1712
1746
  */
1713
- angular.module('ngMockE2E', ['ng']).config(function($provide) {
1747
+ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
1714
1748
  $provide.decorator('$httpBackend', angular.mock.e2e.$httpBackendDecorator);
1715
- });
1749
+ }]);
1716
1750
 
1717
1751
  /**
1718
1752
  * @ngdoc object
@@ -1777,7 +1811,8 @@ angular.module('ngMockE2E', ['ng']).config(function($provide) {
1777
1811
  * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
1778
1812
  * control how a matched request is handled.
1779
1813
  *
1780
- * - respond – `{function([status,] data[, headers])|function(function(method, url, data, headers)}`
1814
+ * - respond –
1815
+ * `{function([status,] data[, headers])|function(function(method, url, data, headers)}`
1781
1816
  * – The respond method takes a set of static data to be returned or a function that can return
1782
1817
  * an array containing response status (number), response data (string) and response headers
1783
1818
  * (Object).
@@ -1879,7 +1914,8 @@ angular.module('ngMockE2E', ['ng']).config(function($provide) {
1879
1914
  * control how a matched request is handled.
1880
1915
  */
1881
1916
  angular.mock.e2e = {};
1882
- angular.mock.e2e.$httpBackendDecorator = ['$rootScope', '$delegate', '$browser', createHttpBackendMock];
1917
+ angular.mock.e2e.$httpBackendDecorator =
1918
+ ['$rootScope', '$delegate', '$browser', createHttpBackendMock];
1883
1919
 
1884
1920
 
1885
1921
  angular.mock.clearDataCache = function() {
@@ -1951,7 +1987,7 @@ angular.mock.clearDataCache = function() {
1951
1987
  *
1952
1988
  * @param {...(string|Function|Object)} fns any number of modules which are represented as string
1953
1989
  * aliases or as anonymous module initialization functions. The modules are used to
1954
- * configure the injector. The 'ng' and 'ngMock' modules are automatically loaded. If an
1990
+ * configure the injector. The 'ng' and 'ngMock' modules are automatically loaded. If an
1955
1991
  * object literal is passed they will be register as values in the module, the key being
1956
1992
  * the module name and the value being what is returned.
1957
1993
  */
@@ -1961,7 +1997,7 @@ angular.mock.clearDataCache = function() {
1961
1997
  /////////////////////
1962
1998
  function workFn() {
1963
1999
  if (currentSpec.$injector) {
1964
- throw Error('Injector already created, can not register a module!');
2000
+ throw new Error('Injector already created, can not register a module!');
1965
2001
  } else {
1966
2002
  var modules = currentSpec.$modules || (currentSpec.$modules = []);
1967
2003
  angular.forEach(moduleFns, function(module) {
@@ -1994,17 +2030,17 @@ angular.mock.clearDataCache = function() {
1994
2030
  * ## Resolving References (Underscore Wrapping)
1995
2031
  * Often, we would like to inject a reference once, in a `beforeEach()` block and reuse this
1996
2032
  * in multiple `it()` clauses. To be able to do this we must assign the reference to a variable
1997
- * that is declared in the scope of the `describe()` block. Since we would, most likely, want
2033
+ * that is declared in the scope of the `describe()` block. Since we would, most likely, want
1998
2034
  * the variable to have the same name of the reference we have a problem, since the parameter
1999
2035
  * to the `inject()` function would hide the outer variable.
2000
2036
  *
2001
2037
  * To help with this, the injected parameters can, optionally, be enclosed with underscores.
2002
2038
  * These are ignored by the injector when the reference name is resolved.
2003
- *
2039
+ *
2004
2040
  * For example, the parameter `_myService_` would be resolved as the reference `myService`.
2005
2041
  * Since it is available in the function body as _myService_, we can then assign it to a variable
2006
2042
  * defined in an outer scope.
2007
- *
2043
+ *
2008
2044
  * ```
2009
2045
  * // Defined out reference variable outside
2010
2046
  * var myService;
@@ -2012,15 +2048,15 @@ angular.mock.clearDataCache = function() {
2012
2048
  * // Wrap the parameter in underscores
2013
2049
  * beforeEach( inject( function(_myService_){
2014
2050
  * myService = _myService_;
2015
- * }));
2051
+ * }));
2016
2052
  *
2017
2053
  * // Use myService in a series of tests.
2018
2054
  * it('makes use of myService', function() {
2019
2055
  * myService.doStuff();
2020
2056
  * });
2021
- *
2057
+ *
2022
2058
  * ```
2023
- *
2059
+ *
2024
2060
  * See also {@link angular.mock.module angular.mock.module}
2025
2061
  *
2026
2062
  * ## Example
@@ -2060,7 +2096,7 @@ angular.mock.clearDataCache = function() {
2060
2096
  * });
2061
2097
  *
2062
2098
  * </pre>
2063
- *
2099
+ *
2064
2100
  * @param {...Function} fns any number of functions which will be injected using the injector.
2065
2101
  */
2066
2102
  window.inject = angular.mock.inject = function() {
@@ -2079,7 +2115,9 @@ angular.mock.clearDataCache = function() {
2079
2115
  }
2080
2116
  for(var i = 0, ii = blockFns.length; i < ii; i++) {
2081
2117
  try {
2118
+ /* jshint -W040 *//* Jasmine explicitly provides a `this` object when calling functions */
2082
2119
  injector.invoke(blockFns[i] || angular.noop, this);
2120
+ /* jshint +W040 */
2083
2121
  } catch (e) {
2084
2122
  if(e.stack && errorForStack) e.stack += '\n' + errorForStack.stack;
2085
2123
  throw e;
@@ -2089,4 +2127,4 @@ angular.mock.clearDataCache = function() {
2089
2127
  }
2090
2128
  }
2091
2129
  };
2092
- })(window);
2130
+ })(window);