1
1
/**
2
- * @license AngularJS v1.3.0-rc.1
2
+ * @license AngularJS v1.3.0
3
3
* (c) 2010-2014 Google, Inc. http://angularjs.org
4
4
* License: MIT
5
5
*/
@@ -53,9 +53,10 @@ angular.mock.$Browser = function() {
53
53
self . onUrlChange = function ( listener ) {
54
54
self . pollFns . push (
55
55
function ( ) {
56
- if ( self . $$lastUrl != self . $$url ) {
56
+ if ( self . $$lastUrl !== self . $$url || self . $$state !== self . $$lastState ) {
57
57
self . $$lastUrl = self . $$url ;
58
- listener ( self . $$url ) ;
58
+ self . $$lastState = self . $$state ;
59
+ listener ( self . $$url , self . $$state ) ;
59
60
}
60
61
}
61
62
) ;
@@ -151,15 +152,24 @@ angular.mock.$Browser.prototype = {
151
152
return pollFn ;
152
153
} ,
153
154
154
- url : function ( url , replace ) {
155
+ url : function ( url , replace , state ) {
156
+ if ( angular . isUndefined ( state ) ) {
157
+ state = null ;
158
+ }
155
159
if ( url ) {
156
160
this . $$url = url ;
161
+ // Native pushState serializes & copies the object; simulate it.
162
+ this . $$state = angular . copy ( state ) ;
157
163
return this ;
158
164
}
159
165
160
166
return this . $$url ;
161
167
} ,
162
168
169
+ state : function ( ) {
170
+ return this . $$state ;
171
+ } ,
172
+
163
173
cookies : function ( name , value ) {
164
174
if ( name ) {
165
175
if ( angular . isUndefined ( value ) ) {
@@ -191,7 +201,7 @@ angular.mock.$Browser.prototype = {
191
201
*
192
202
* @description
193
203
* Configures the mock implementation of {@link ng.$exceptionHandler} to rethrow or to log errors
194
- * passed into the `$exceptionHandler`.
204
+ * passed to the `$exceptionHandler`.
195
205
*/
196
206
197
207
/**
@@ -200,7 +210,7 @@ angular.mock.$Browser.prototype = {
200
210
*
201
211
* @description
202
212
* Mock implementation of {@link ng.$exceptionHandler} that rethrows or logs errors passed
203
- * into it. See {@link ngMock.$exceptionHandlerProvider $exceptionHandlerProvider} for configuration
213
+ * to it. See {@link ngMock.$exceptionHandlerProvider $exceptionHandlerProvider} for configuration
204
214
* information.
205
215
*
206
216
*
@@ -240,9 +250,8 @@ angular.mock.$ExceptionHandlerProvider = function() {
240
250
*
241
251
* @param {string } mode Mode of operation, defaults to `rethrow`.
242
252
*
243
- * - `rethrow`: If any errors are passed into the handler in tests, it typically
244
- * means that there is a bug in the application or test, so this mock will
245
- * make these tests fail.
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.
246
255
* - `log`: Sometimes it is desirable to test that an error is thrown, for this case the `log`
247
256
* mode stores an array of errors in `$exceptionHandler.errors`, to allow later
248
257
* assertion of them. See {@link ngMock.$log#assertEmpty assertEmpty()} and
@@ -333,7 +342,7 @@ angular.mock.$LogProvider = function() {
333
342
* @name $log#log.logs
334
343
*
335
344
* @description
336
- * Array of messages logged using {@link ngMock .$log#log}.
345
+ * Array of messages logged using {@link ng .$log#log `log()` }.
337
346
*
338
347
* @example
339
348
* ```js
@@ -347,7 +356,7 @@ angular.mock.$LogProvider = function() {
347
356
* @name $log#info.logs
348
357
*
349
358
* @description
350
- * Array of messages logged using {@link ngMock .$log#info}.
359
+ * Array of messages logged using {@link ng .$log#info `info()` }.
351
360
*
352
361
* @example
353
362
* ```js
@@ -361,7 +370,7 @@ angular.mock.$LogProvider = function() {
361
370
* @name $log#warn.logs
362
371
*
363
372
* @description
364
- * Array of messages logged using {@link ngMock .$log#warn}.
373
+ * Array of messages logged using {@link ng .$log#warn `warn()` }.
365
374
*
366
375
* @example
367
376
* ```js
@@ -375,7 +384,7 @@ angular.mock.$LogProvider = function() {
375
384
* @name $log#error.logs
376
385
*
377
386
* @description
378
- * Array of messages logged using {@link ngMock .$log#error}.
387
+ * Array of messages logged using {@link ng .$log#error `error()` }.
379
388
*
380
389
* @example
381
390
* ```js
@@ -389,7 +398,7 @@ angular.mock.$LogProvider = function() {
389
398
* @name $log#debug.logs
390
399
*
391
400
* @description
392
- * Array of messages logged using {@link ngMock .$log#debug}.
401
+ * Array of messages logged using {@link ng .$log#debug `debug()` }.
393
402
*
394
403
* @example
395
404
* ```js
@@ -405,8 +414,8 @@ angular.mock.$LogProvider = function() {
405
414
* @name $log#assertEmpty
406
415
*
407
416
* @description
408
- * Assert that the all of the logging methods have no logged messages. If messages present, an
409
- * exception is thrown.
417
+ * Assert that all of the logging methods have no logged messages. If any messages are present,
418
+ * an exception is thrown.
410
419
*/
411
420
$log . assertEmpty = function ( ) {
412
421
var errors = [ ] ;
@@ -801,11 +810,12 @@ angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
801
810
} ;
802
811
803
812
angular . forEach (
804
- [ 'enter' , 'leave' , 'move' , 'addClass' , 'removeClass' , 'setClass' ] , function ( method ) {
813
+ [ 'animate' , ' enter', 'leave' , 'move' , 'addClass' , 'removeClass' , 'setClass' ] , function ( method ) {
805
814
animate [ method ] = function ( ) {
806
815
animate . queue . push ( {
807
816
event : method ,
808
817
element : arguments [ 0 ] ,
818
+ options : arguments [ arguments . length - 1 ] ,
809
819
args : arguments
810
820
} ) ;
811
821
return $delegate [ method ] . apply ( $delegate , arguments ) ;
@@ -991,6 +1001,11 @@ angular.mock.dump = function(object) {
991
1001
* First we create the controller under test:
992
1002
*
993
1003
```js
1004
+ // The module code
1005
+ angular
1006
+ .module('MyApp', [])
1007
+ .controller('MyController', MyController);
1008
+
994
1009
// The controller code
995
1010
function MyController($scope, $http) {
996
1011
var authToken;
@@ -1020,6 +1035,9 @@ angular.mock.dump = function(object) {
1020
1035
describe('MyController', function() {
1021
1036
var $httpBackend, $rootScope, createController, authRequestHandler;
1022
1037
1038
+ // Set up the module
1039
+ beforeEach(module('MyApp'));
1040
+
1023
1041
beforeEach(inject(function($injector) {
1024
1042
// Set up the mock http service responses
1025
1043
$httpBackend = $injector.get('$httpBackend');
0 commit comments