@@ -22,6 +22,12 @@ CoreManager.set('APPLICATION_ID', 'A');
2222CoreManager . set ( 'JAVASCRIPT_KEY' , 'B' ) ;
2323CoreManager . set ( 'VERSION' , 'V' ) ;
2424
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+
2531describe ( 'RESTController' , ( ) => {
2632 it ( 'throws if there is no XHR implementation' , ( ) => {
2733 RESTController . _setXHR ( null ) ;
@@ -212,45 +218,39 @@ describe('RESTController', () => {
212218 XHR . prototype = {
213219 open : function ( ) { } ,
214220 setRequestHeader : function ( ) { } ,
215- getResponseHeader : function ( ) {
216- return 1234 ;
221+ getResponseHeader : function ( header ) {
222+ return headers [ header ] ;
217223 } ,
218224 send : function ( ) {
219225 this . status = 200 ;
220226 this . responseText = '{}' ;
221227 this . readyState = 4 ;
222228 this . onreadystatechange ( ) ;
223229 } ,
224- getAllResponseHeaders : function ( ) {
225- return 'x-parse-job-status-id: 1234' ;
226- } ,
227230 } ;
228231 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' ) ;
231234 } ) ;
232235
233236 it ( 'handles x-parse-push-status-id header' , async ( ) => {
234237 const XHR = function ( ) { } ;
235238 XHR . prototype = {
236239 open : function ( ) { } ,
237240 setRequestHeader : function ( ) { } ,
238- getResponseHeader : function ( ) {
239- return 1234 ;
241+ getResponseHeader : function ( header ) {
242+ return headers [ header ] ;
240243 } ,
241244 send : function ( ) {
242245 this . status = 200 ;
243246 this . responseText = '{}' ;
244247 this . readyState = 4 ;
245248 this . onreadystatechange ( ) ;
246249 } ,
247- getAllResponseHeaders : function ( ) {
248- return 'x-parse-push-status-id: 1234' ;
249- } ,
250250 } ;
251251 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' ) ;
254254 } ) ;
255255
256256 it ( 'handles invalid header' , async ( ) => {
0 commit comments