@@ -1127,63 +1127,15 @@ describe("$http", function () {
11271127 } ) ;
11281128 } ) ;
11291129
1130- describe ( "useApplyAsync" , function ( ) {
1131- beforeEach ( function ( ) {
1132- const injector = createInjector ( [
1133- "ng" ,
1134- function ( $httpProvider ) {
1135- $httpProvider . useApplyAsync ( true ) ;
1136- } ,
1137- ] ) ;
1138- $http = injector . get ( "$http" ) ;
1139- $rootScope = injector . get ( "$rootScope" ) ;
1140- } ) ;
1141-
1142- it ( "does not resolve promise immediately when enabled" , async function ( ) {
1143- const resolvedSpy = jasmine . createSpy ( ) ;
1144- $http . get ( "/mock/hello" ) . then ( resolvedSpy ) ;
1145- await wait ( ) ;
1146-
1147- expect ( resolvedSpy ) . not . toHaveBeenCalled ( ) ;
1148- } ) ;
1149-
1150- it ( "resolves promise later when enabled" , async function ( ) {
1151- const resolvedSpy = jasmine . createSpy ( ) ;
1152- await $http . get ( "/mock/hello" ) . then ( resolvedSpy ) ;
1153- await wait ( ) ;
1130+ it ( "calls configured event handlers" , async function ( ) {
1131+ const loadSpy = jasmine . createSpy ( "load" ) ;
11541132
1155- expect ( resolvedSpy ) . toHaveBeenCalled ( ) ;
1133+ await $http . get ( "/mock/hello" , {
1134+ eventHandlers : { load : loadSpy } ,
11561135 } ) ;
11571136
1158- it ( "defers configured event handlers when enabled" , async function ( ) {
1159- const loadSpy = jasmine . createSpy ( "load" ) ;
1160-
1161- await $http . get ( "/mock/hello" , {
1162- eventHandlers : { load : loadSpy } ,
1163- } ) ;
1164-
1165- await wait ( ) ;
1166- expect ( loadSpy ) . toHaveBeenCalled ( ) ;
1167- } ) ;
1168- } ) ;
1169-
1170- describe ( "provider configuration" , function ( ) {
1171- it ( "returns the current deferred response setting" , function ( ) {
1172- let initial ;
1173- let updated ;
1174-
1175- createInjector ( [
1176- "ng" ,
1177- function ( $httpProvider ) {
1178- initial = $httpProvider . useApplyAsync ( ) ;
1179- $httpProvider . useApplyAsync ( true ) ;
1180- updated = $httpProvider . useApplyAsync ( ) ;
1181- } ,
1182- ] ) ;
1183-
1184- expect ( initial ) . toBe ( false ) ;
1185- expect ( updated ) . toBe ( true ) ;
1186- } ) ;
1137+ await wait ( ) ;
1138+ expect ( loadSpy ) . toHaveBeenCalled ( ) ;
11871139 } ) ;
11881140} ) ;
11891141
@@ -3921,98 +3873,6 @@ describe("http", () => {
39213873// });
39223874// });
39233875
3924- // describe("$http with deferred delivery", () => {
3925- // let $http;
3926- // let $httpBackend;
3927- // let $rootScope;
3928- // let $browser;
3929- // let log;
3930-
3931- // beforeEach(inject([
3932- // "$http",
3933- // "$httpBackend",
3934- // "$rootScope",
3935- // "$browser",
3936- // "log",
3937- // function (http, backend, scope, browser, logger) {
3938- // $http = http;
3939- // $httpBackend = backend;
3940- // $rootScope = scope;
3941- // $browser = browser;
3942- // spyOn($rootScope, "digest entry").and.callThrough();
3943- // spyOn($rootScope, "deferred delivery").and.callThrough();
3944- // spyOn($rootScope, "$digest").and.callThrough();
3945- // spyOn($browser.defer, "cancel").and.callThrough();
3946- // log = logger;
3947- // },
3948- // ]));
3949-
3950- // it("should schedule coalesced apply on response", () => {
3951- // const handler = jasmine.createSpy("handler");
3952- // $httpBackend
3953- // .expect("GET", "/template1.html")
3954- // .respond(200, "<h1>Header!</h1>", {});
3955- // $http.get("/template1.html").then(handler);
3956- // // Ensure requests are sent
3957- // ;
3958-
3959- // $httpBackend.flush(null, null, false);
3960- // expect($rootScope.deferred delivery).toHaveBeenCalled();
3961- // expect(handler).not.toHaveBeenCalled();
3962-
3963- // $browser.defer.flush();
3964- // expect(handler).toHaveBeenCalled();
3965- // });
3966-
3967- // it("should combine multiple responses within short time frame into a single digest entry", () => {
3968- // $httpBackend
3969- // .expect("GET", "/template1.html")
3970- // .respond(200, "<h1>Header!</h1>", {});
3971- // $httpBackend
3972- // .expect("GET", "/template2.html")
3973- // .respond(200, "<p>Body!</p>", {});
3974-
3975- // $http.get("/template1.html").then(log.fn("response 1"));
3976- // $http.get("/template2.html").then(log.fn("response 2"));
3977- // // Ensure requests are sent
3978- // ;
3979-
3980- // $httpBackend.flush(null, null, false);
3981- // expect(log).toEqual([]);
3982-
3983- // $browser.defer.flush();
3984- // expect(log).toEqual(["response 1", "response 2"]);
3985- // });
3986-
3987- // it("should handle pending responses immediately if a digest occurs on $rootScope", () => {
3988- // $httpBackend
3989- // .expect("GET", "/template1.html")
3990- // .respond(200, "<h1>Header!</h1>", {});
3991- // $httpBackend
3992- // .expect("GET", "/template2.html")
3993- // .respond(200, "<p>Body!</p>", {});
3994- // $httpBackend
3995- // .expect("GET", "/template3.html")
3996- // .respond(200, "<p>Body!</p>", {});
3997-
3998- // $http.get("/template1.html").then(log.fn("response 1"));
3999- // $http.get("/template2.html").then(log.fn("response 2"));
4000- // $http.get("/template3.html").then(log.fn("response 3"));
4001- // // Ensure requests are sent
4002- // ;
4003-
4004- // // Intermediate $digest occurs before 3rd response is received, assert that pending responses
4005- // /// are handled
4006- // $httpBackend.flush(2);
4007- // expect(log).toEqual(["response 1", "response 2"]);
4008-
4009- // // Finally, third response is received, and a second coalesced digest entry is started
4010- // $httpBackend.flush(null, null, false);
4011- // $browser.defer.flush();
4012- // expect(log).toEqual(["response 1", "response 2", "response 3"]);
4013- // });
4014- // });
4015-
40163876// describe("$http param serializers", () => {
40173877// let defSer;
40183878// let jqrSer;
0 commit comments