@@ -22,6 +22,12 @@ CoreManager.set('APPLICATION_ID', 'A');
22
22
CoreManager . set ( 'JAVASCRIPT_KEY' , 'B' ) ;
23
23
CoreManager . set ( 'VERSION' , 'V' ) ;
24
24
25
+ const headers = {
26
+ 'x-parse-job-status-id' : '1234' ,
27
+ 'x-parse-push-status-id' : '5678' ,
28
+ 'access-control-expose-headers' : 'X-Parse-Job-Status-Id, X-Parse-Push-Status-Id' ,
29
+ } ;
30
+
25
31
describe ( 'RESTController' , ( ) => {
26
32
it ( 'throws if there is no XHR implementation' , ( ) => {
27
33
RESTController . _setXHR ( null ) ;
@@ -212,45 +218,39 @@ describe('RESTController', () => {
212
218
XHR . prototype = {
213
219
open : function ( ) { } ,
214
220
setRequestHeader : function ( ) { } ,
215
- getResponseHeader : function ( ) {
216
- return 1234 ;
221
+ getResponseHeader : function ( header ) {
222
+ return headers [ header ] ;
217
223
} ,
218
224
send : function ( ) {
219
225
this . status = 200 ;
220
226
this . responseText = '{}' ;
221
227
this . readyState = 4 ;
222
228
this . onreadystatechange ( ) ;
223
229
} ,
224
- getAllResponseHeaders : function ( ) {
225
- return 'x-parse-job-status-id: 1234' ;
226
- } ,
227
230
} ;
228
231
RESTController . _setXHR ( XHR ) ;
229
- const response = await RESTController . request ( 'GET' , 'classes/MyObject' , { } , { } ) ;
230
- expect ( response ) . toBe ( 1234 ) ;
232
+ const response = await RESTController . request ( 'GET' , 'classes/MyObject' , { } , { returnStatus : true } ) ;
233
+ expect ( response . _headers [ 'X-Parse-Job-Status-Id' ] ) . toBe ( ' 1234' ) ;
231
234
} ) ;
232
235
233
236
it ( 'handles x-parse-push-status-id header' , async ( ) => {
234
237
const XHR = function ( ) { } ;
235
238
XHR . prototype = {
236
239
open : function ( ) { } ,
237
240
setRequestHeader : function ( ) { } ,
238
- getResponseHeader : function ( ) {
239
- return 1234 ;
241
+ getResponseHeader : function ( header ) {
242
+ return headers [ header ] ;
240
243
} ,
241
244
send : function ( ) {
242
245
this . status = 200 ;
243
246
this . responseText = '{}' ;
244
247
this . readyState = 4 ;
245
248
this . onreadystatechange ( ) ;
246
249
} ,
247
- getAllResponseHeaders : function ( ) {
248
- return 'x-parse-push-status-id: 1234' ;
249
- } ,
250
250
} ;
251
251
RESTController . _setXHR ( XHR ) ;
252
- const response = await RESTController . request ( 'POST' , 'push' , { } , { } ) ;
253
- expect ( response ) . toBe ( 1234 ) ;
252
+ const response = await RESTController . request ( 'POST' , 'push' , { } , { returnStatus : true } ) ;
253
+ expect ( response . _headers [ 'X-Parse-Push-Status-Id' ] ) . toBe ( '5678' ) ;
254
254
} ) ;
255
255
256
256
it ( 'handles invalid header' , async ( ) => {
0 commit comments