@@ -152,7 +152,14 @@ function MockBrowser() {
152
152
throw new Error ( "Missing HTTP request header: " + key + ": " + value ) ;
153
153
}
154
154
} ) ;
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
+ } ) ;
156
163
} ) ;
157
164
} ;
158
165
self . xhr . expectations = expectations ;
@@ -162,12 +169,22 @@ function MockBrowser() {
162
169
if ( data && angular . isString ( data ) ) url += "|" + data ;
163
170
var expect = expectations [ method ] || ( expectations [ method ] = { } ) ;
164
171
return {
165
- respond : function ( code , response ) {
172
+ respond : function ( code , response , responseHeaders ) {
166
173
if ( ! angular . isNumber ( code ) ) {
174
+ responseHeaders = response ;
167
175
response = code ;
168
176
code = 200 ;
169
177
}
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
+ } ;
171
188
}
172
189
} ;
173
190
} ;
@@ -268,7 +285,7 @@ function MockBrowser() {
268
285
self . defer = function ( fn , delay ) {
269
286
delay = delay || 0 ;
270
287
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 ; } ) ;
272
289
return self . deferredNextId ++ ;
273
290
} ;
274
291
@@ -374,7 +391,7 @@ angular.service('$browser', function(){
374
391
* See {@link angular.mock} for more info on angular mocks.
375
392
*/
376
393
angular . service ( '$exceptionHandler' , function ( ) {
377
- return function ( e ) { throw e ; } ;
394
+ return function ( e ) { throw e ; } ;
378
395
} ) ;
379
396
380
397
@@ -394,10 +411,10 @@ angular.service('$log', MockLogFactory);
394
411
395
412
function MockLogFactory ( ) {
396
413
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 ) ; }
401
418
} ;
402
419
403
420
$log . log . logs = [ ] ;
0 commit comments