@@ -293,7 +293,7 @@ describe('$http', function() {
293
293
$httpBackend = $hb ;
294
294
$http = $h ;
295
295
$rootScope = $rs ;
296
- spyOn ( $rootScope , '$apply ' ) . andCallThrough ( ) ;
296
+ spyOn ( $rootScope , '$evalAsync ' ) . andCallThrough ( ) ;
297
297
} ] ) ) ;
298
298
299
299
it ( 'should throw error if the request configuration is not an object' , function ( ) {
@@ -1012,31 +1012,37 @@ describe('$http', function() {
1012
1012
} ) ;
1013
1013
1014
1014
1015
- describe ( 'scope.$apply ' , function ( ) {
1015
+ describe ( '$rootScope.$evalAsync ' , function ( ) {
1016
1016
1017
- it ( 'should $apply after success callback' , function ( ) {
1018
- $httpBackend . when ( 'GET' ) . respond ( 200 ) ;
1019
- $http ( { method : 'GET' , url : '/some' } ) ;
1020
- $httpBackend . flush ( ) ;
1021
- expect ( $rootScope . $apply ) . toHaveBeenCalledOnce ( ) ;
1017
+ it ( 'should $evalAsync after success callback' , function ( ) {
1018
+ $httpBackend . whenGET ( ) . respond ( 200 ) ;
1019
+ $http . get ( '/some' ) ;
1020
+ $rootScope . $digest ( ) ; // Send the request
1021
+ $rootScope . $evalAsync . reset ( ) ;
1022
+ $httpBackend . flush ( null , false ) ;
1023
+ expect ( $rootScope . $evalAsync ) . toHaveBeenCalledOnce ( ) ;
1022
1024
} ) ;
1023
1025
1024
1026
1025
- it ( 'should $apply after error callback' , function ( ) {
1026
- $httpBackend . when ( 'GET' ) . respond ( 404 ) ;
1027
- $http ( { method : 'GET' , url : '/some' } ) ;
1028
- $httpBackend . flush ( ) ;
1029
- expect ( $rootScope . $apply ) . toHaveBeenCalledOnce ( ) ;
1027
+ it ( 'should $evalAsync after error callback' , function ( ) {
1028
+ $httpBackend . whenGET ( ) . respond ( 404 ) ;
1029
+ $http . get ( '/some' ) ;
1030
+ $rootScope . $digest ( ) ; // Send the request
1031
+ $rootScope . $evalAsync . reset ( ) ;
1032
+ $httpBackend . flush ( null , false ) ;
1033
+ expect ( $rootScope . $evalAsync ) . toHaveBeenCalledOnce ( ) ;
1030
1034
} ) ;
1031
1035
1032
1036
1033
- it ( 'should $apply even if exception thrown during callback' , inject ( function ( $exceptionHandler ) {
1034
- $httpBackend . when ( 'GET' ) . respond ( 200 ) ;
1037
+ it ( 'should $evalAsync even if exception thrown during callback' , inject ( function ( $exceptionHandler ) {
1038
+ $httpBackend . whenGET ( ) . respond ( 200 ) ;
1035
1039
callback . andThrow ( 'error in callback' ) ;
1036
1040
1037
- $http ( { method : 'GET' , url : '/some' } ) . then ( callback ) ;
1038
- $httpBackend . flush ( ) ;
1039
- expect ( $rootScope . $apply ) . toHaveBeenCalledOnce ( ) ;
1041
+ $http . get ( '/some' ) ;
1042
+ $rootScope . $digest ( ) ; // Send the request
1043
+ $rootScope . $evalAsync . reset ( ) ;
1044
+ $httpBackend . flush ( null , false ) ;
1045
+ expect ( $rootScope . $evalAsync ) . toHaveBeenCalledOnce ( ) ;
1040
1046
1041
1047
$exceptionHandler . errors = [ ] ;
1042
1048
} ) ) ;
@@ -1921,9 +1927,7 @@ describe('$http', function() {
1921
1927
1922
1928
describe ( '$http with $applyAsync' , function ( ) {
1923
1929
var $http , $httpBackend , $rootScope , $browser , log ;
1924
- beforeEach ( module ( function ( $httpProvider ) {
1925
- $httpProvider . useApplyAsync ( true ) ;
1926
- } , provideLog ) ) ;
1930
+ beforeEach ( module ( provideLog ) ) ;
1927
1931
1928
1932
1929
1933
beforeEach ( inject ( [ '$http' , '$httpBackend' , '$rootScope' , '$browser' , 'log' , function ( http , backend , scope , browser , logger ) {
@@ -1939,15 +1943,14 @@ describe('$http with $applyAsync', function() {
1939
1943
} ] ) ) ;
1940
1944
1941
1945
1942
- it ( 'should schedule coalesced apply on response' , function ( ) {
1946
+ it ( 'should defer response handling ' , function ( ) {
1943
1947
var handler = jasmine . createSpy ( 'handler' ) ;
1944
1948
$httpBackend . expect ( 'GET' , '/template1.html' ) . respond ( 200 , '<h1>Header!</h1>' , { } ) ;
1945
1949
$http . get ( '/template1.html' ) . then ( handler ) ;
1946
1950
// Ensure requests are sent
1947
1951
$rootScope . $digest ( ) ;
1948
1952
1949
1953
$httpBackend . flush ( null , false ) ;
1950
- expect ( $rootScope . $applyAsync ) . toHaveBeenCalledOnce ( ) ;
1951
1954
expect ( handler ) . not . toHaveBeenCalled ( ) ;
1952
1955
1953
1956
$browser . defer . flush ( ) ;
0 commit comments