From 4ae46814ff4e7c0bbcdbbefc0a97277283a84065 Mon Sep 17 00:00:00 2001 From: Sylvester Keil Date: Tue, 26 Feb 2013 10:22:12 +0100 Subject: feat(http): support request/response promise chaining myApp.factory('myAroundInterceptor', function($rootScope, $timeout) { return function(configPromise, responsePromise) { return { request: configPromise.then(function(config) { return config }); response: responsePromise.then(function(response) { return 'ha!'; } }); } myApp.config(function($httpProvider){ $httpProvider.aroundInterceptors.push('myAroundInterceptor'); }); --- test/ng/directive/ngIncludeSpec.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'test/ng/directive') diff --git a/test/ng/directive/ngIncludeSpec.js b/test/ng/directive/ngIncludeSpec.js index 7c94a70e..dce803b5 100644 --- a/test/ng/directive/ngIncludeSpec.js +++ b/test/ng/directive/ngIncludeSpec.js @@ -178,25 +178,23 @@ describe('ngInclude', function() { it('should discard pending xhr callbacks if a new template is requested before the current ' + 'finished loading', inject(function($rootScope, $compile, $httpBackend) { element = jqLite(""); - var log = []; + var log = {}; $rootScope.templateUrl = 'myUrl1'; $rootScope.logger = function(msg) { - log.push(msg); + log[msg] = true; } $compile(element)($rootScope); - expect(log.join('; ')).toEqual(''); + expect(log).toEqual({}); $httpBackend.expect('GET', 'myUrl1').respond('
{{logger("url1")}}
'); $rootScope.$digest(); - expect(log.join('; ')).toEqual(''); + expect(log).toEqual({}); $rootScope.templateUrl = 'myUrl2'; $httpBackend.expect('GET', 'myUrl2').respond('
{{logger("url2")}}
'); - $rootScope.$digest(); $httpBackend.flush(); // now that we have two requests pending, flush! - expect(log.join('; ')).toEqual('url2; url2'); // it's here twice because we go through at - // least two digest cycles + expect(log).toEqual({ url2 : true }); })); -- cgit v1.2.3