@@ -152,7 +152,14 @@ function MockBrowser() {
152152 throw new Error ( "Missing HTTP request header: " + key + ": " + value ) ;
153153 }
154154 } ) ;
155- callback ( expectation . code , expectation . response ) ;
155+ callback ( expectation . code , expectation . response , function ( header ) {
156+ if ( header ) {
157+ header = header . toLowerCase ( ) ;
158+ return expectation . responseHeaders && expectation . responseHeaders [ header ] || null ;
159+ } else {
160+ return expectation . responseHeaders || { } ;
161+ }
162+ } ) ;
156163 } ) ;
157164 } ;
158165 self . xhr . expectations = expectations ;
@@ -162,12 +169,22 @@ function MockBrowser() {
162169 if ( data && angular . isString ( data ) ) url += "|" + data ;
163170 var expect = expectations [ method ] || ( expectations [ method ] = { } ) ;
164171 return {
165- respond : function ( code , response ) {
172+ respond : function ( code , response , responseHeaders ) {
166173 if ( ! angular . isNumber ( code ) ) {
174+ responseHeaders = response ;
167175 response = code ;
168176 code = 200 ;
169177 }
170- expect [ url ] = { code :code , response :response , headers : headers || { } } ;
178+ angular . forEach ( responseHeaders , function ( value , key ) {
179+ delete responseHeaders [ key ] ;
180+ responseHeaders [ key . toLowerCase ( ) ] = value ;
181+ } ) ;
182+ expect [ url ] = {
183+ code : code ,
184+ response : response ,
185+ headers : headers || { } ,
186+ responseHeaders : responseHeaders || { }
187+ } ;
171188 }
172189 } ;
173190 } ;
@@ -268,7 +285,7 @@ function MockBrowser() {
268285 self . defer = function ( fn , delay ) {
269286 delay = delay || 0 ;
270287 self . deferredFns . push ( { time :( self . defer . now + delay ) , fn :fn , id : self . deferredNextId } ) ;
271- self . deferredFns . sort ( function ( a , b ) { return a . time - b . time ; } ) ;
288+ self . deferredFns . sort ( function ( a , b ) { return a . time - b . time ; } ) ;
272289 return self . deferredNextId ++ ;
273290 } ;
274291
@@ -374,7 +391,7 @@ angular.service('$browser', function(){
374391 * See {@link angular.mock} for more info on angular mocks.
375392 */
376393angular . service ( '$exceptionHandler' , function ( ) {
377- return function ( e ) { throw e ; } ;
394+ return function ( e ) { throw e ; } ;
378395} ) ;
379396
380397
@@ -394,10 +411,10 @@ angular.service('$log', MockLogFactory);
394411
395412function MockLogFactory ( ) {
396413 var $log = {
397- log : function ( ) { $log . log . logs . push ( arguments ) ; } ,
398- warn : function ( ) { $log . warn . logs . push ( arguments ) ; } ,
399- info : function ( ) { $log . info . logs . push ( arguments ) ; } ,
400- error : function ( ) { $log . error . logs . push ( arguments ) ; }
414+ log : function ( ) { $log . log . logs . push ( arguments ) ; } ,
415+ warn : function ( ) { $log . warn . logs . push ( arguments ) ; } ,
416+ info : function ( ) { $log . info . logs . push ( arguments ) ; } ,
417+ error : function ( ) { $log . error . logs . push ( arguments ) ; }
401418 } ;
402419
403420 $log . log . logs = [ ] ;
0 commit comments