1
1
/**
2
- * @license AngularJS v1.2.10
2
+ * @license AngularJS v1.2.13
3
3
* (c) 2010-2014 Google, Inc. http://angularjs.org
4
4
* License: MIT
5
5
*/
@@ -511,6 +511,7 @@ angular.mock.$IntervalProvider = function() {
511
511
} ;
512
512
513
513
$interval . cancel = function ( promise ) {
514
+ if ( ! promise ) return false ;
514
515
var fnIndex ;
515
516
516
517
angular . forEach ( repeatFns , function ( fn , index ) {
@@ -763,70 +764,40 @@ angular.mock.TzDate = function (offset, timestamp) {
763
764
angular . mock . TzDate . prototype = Date . prototype ;
764
765
/* jshint +W101 */
765
766
766
- // TODO(matias): remove this IMMEDIATELY once we can properly detect the
767
- // presence of a registered module
768
- var animateLoaded ;
769
- try {
770
- angular . module ( 'ngAnimate' ) ;
771
- animateLoaded = true ;
772
- } catch ( e ) { }
767
+ angular . mock . animate = angular . module ( 'ngAnimateMock' , [ 'ng' ] )
773
768
774
- if ( animateLoaded ) {
775
- angular . module ( 'ngAnimate' ) . config ( [ '$provide' , function ( $provide ) {
769
+ . config ( [ '$provide' , function ( $provide ) {
776
770
var reflowQueue = [ ] ;
771
+
777
772
$provide . value ( '$$animateReflow' , function ( fn ) {
778
773
reflowQueue . push ( fn ) ;
779
774
return angular . noop ;
780
775
} ) ;
781
- $provide . decorator ( '$animate' , function ( $delegate ) {
782
- $delegate . triggerReflow = function ( ) {
783
- if ( reflowQueue . length === 0 ) {
784
- throw new Error ( 'No animation reflows present' ) ;
785
- }
786
- angular . forEach ( reflowQueue , function ( fn ) {
787
- fn ( ) ;
788
- } ) ;
789
- reflowQueue = [ ] ;
790
- } ;
791
- return $delegate ;
792
- } ) ;
793
- } ] ) ;
794
- }
795
-
796
- angular . mock . animate = angular . module ( 'mock.animate' , [ 'ng' ] )
797
-
798
- . config ( [ '$provide' , function ( $provide ) {
799
776
800
777
$provide . decorator ( '$animate' , function ( $delegate ) {
801
778
var animate = {
802
779
queue : [ ] ,
803
780
enabled : $delegate . enabled ,
804
- flushNext : function ( name ) {
805
- var tick = animate . queue . shift ( ) ;
806
-
807
- if ( ! tick ) throw new Error ( 'No animation to be flushed' ) ;
808
- if ( tick . method !== name ) {
809
- throw new Error ( 'The next animation is not "' + name +
810
- '", but is "' + tick . method + '"' ) ;
781
+ triggerReflow : function ( ) {
782
+ if ( reflowQueue . length === 0 ) {
783
+ throw new Error ( 'No animation reflows present' ) ;
811
784
}
812
- tick . fn ( ) ;
813
- return tick ;
785
+ angular . forEach ( reflowQueue , function ( fn ) {
786
+ fn ( ) ;
787
+ } ) ;
788
+ reflowQueue = [ ] ;
814
789
}
815
790
} ;
816
791
817
- angular . forEach ( [ 'enter' , 'leave' , 'move' , 'addClass' , 'removeClass' ] , function ( method ) {
792
+ angular . forEach (
793
+ [ 'enter' , 'leave' , 'move' , 'addClass' , 'removeClass' , 'setClass' ] , function ( method ) {
818
794
animate [ method ] = function ( ) {
819
- var params = arguments ;
820
795
animate . queue . push ( {
821
- method : method ,
822
- params : params ,
823
- element : angular . isElement ( params [ 0 ] ) && params [ 0 ] ,
824
- parent : angular . isElement ( params [ 1 ] ) && params [ 1 ] ,
825
- after : angular . isElement ( params [ 2 ] ) && params [ 2 ] ,
826
- fn : function ( ) {
827
- $delegate [ method ] . apply ( $delegate , params ) ;
828
- }
796
+ event : method ,
797
+ element : arguments [ 0 ] ,
798
+ args : arguments
829
799
} ) ;
800
+ $delegate [ method ] . apply ( $delegate , arguments ) ;
830
801
} ;
831
802
} ) ;
832
803
@@ -996,18 +967,18 @@ angular.mock.dump = function(object) {
996
967
*
997
968
* # Flushing HTTP requests
998
969
*
999
- * The $httpBackend used in production, always responds to requests with responses asynchronously.
1000
- * If we preserved this behavior in unit testing, we'd have to create async unit tests, which are
1001
- * hard to write, follow and maintain. At the same time the testing mock, can't respond
970
+ * The $httpBackend used in production always responds to requests with responses asynchronously.
971
+ * If we preserved this behavior in unit testing we'd have to create async unit tests, which are
972
+ * hard to write, understand, and maintain. However, the testing mock can't respond
1002
973
* synchronously because that would change the execution of the code under test. For this reason the
1003
974
* mock $httpBackend has a `flush()` method, which allows the test to explicitly flush pending
1004
- * requests and thus preserving the async api of the backend, while allowing the test to execute
975
+ * requests and thus preserve the async api of the backend while allowing the test to execute
1005
976
* synchronously.
1006
977
*
1007
978
*
1008
979
* # Unit testing with mock $httpBackend
1009
- * The following code shows how to setup and use the mock backend in unit testing a controller.
1010
- * First we create the controller under test
980
+ * The following code shows how to setup and use the mock backend when unit testing a controller.
981
+ * First we create the controller under test:
1011
982
*
1012
983
<pre>
1013
984
// The controller code
@@ -1032,7 +1003,7 @@ angular.mock.dump = function(object) {
1032
1003
}
1033
1004
</pre>
1034
1005
*
1035
- * Now we setup the mock backend and create the test specs.
1006
+ * Now we setup the mock backend and create the test specs:
1036
1007
*
1037
1008
<pre>
1038
1009
// testing controller
@@ -1954,7 +1925,7 @@ if(window.jasmine || window.mocha) {
1954
1925
1955
1926
var currentSpec = null ,
1956
1927
isSpecRunning = function ( ) {
1957
- return currentSpec && ( window . mocha || currentSpec . queue . running ) ;
1928
+ return ! ! currentSpec ;
1958
1929
} ;
1959
1930
1960
1931
@@ -2132,7 +2103,7 @@ if(window.jasmine || window.mocha) {
2132
2103
window . inject = angular . mock . inject = function ( ) {
2133
2104
var blockFns = Array . prototype . slice . call ( arguments , 0 ) ;
2134
2105
var errorForStack = new Error ( 'Declaration Location' ) ;
2135
- return isSpecRunning ( ) ? workFn ( ) : workFn ;
2106
+ return isSpecRunning ( ) ? workFn . call ( currentSpec ) : workFn ;
2136
2107
/////////////////////
2137
2108
function workFn ( ) {
2138
2109
var modules = currentSpec . $modules || [ ] ;
0 commit comments