@@ -256,4 +256,68 @@ describe('Parse.Session', () => {
256256 expect ( newSession . createdWith . action ) . toBe ( 'create' ) ;
257257 expect ( newSession . createdWith . authProvider ) . toBeUndefined ( ) ;
258258 } ) ;
259+
260+ describe ( 'PUT /sessions/me' , ( ) => {
261+ it ( 'should return error with invalid session token' , async ( ) => {
262+ const response = await request ( {
263+ method : 'PUT' ,
264+ url : 'http://localhost:8378/1/sessions/me' ,
265+ headers : {
266+ 'X-Parse-Application-Id' : 'test' ,
267+ 'X-Parse-REST-API-Key' : 'rest' ,
268+ 'X-Parse-Session-Token' : 'r:invalid-session-token' ,
269+ 'Content-Type' : 'application/json' ,
270+ } ,
271+ body : JSON . stringify ( { } ) ,
272+ } ) . catch ( e => e ) ;
273+ expect ( response . status ) . not . toBe ( 500 ) ;
274+ expect ( response . data . code ) . toBe ( Parse . Error . INVALID_SESSION_TOKEN ) ;
275+ } ) ;
276+
277+ it ( 'should return error without session token' , async ( ) => {
278+ const response = await request ( {
279+ method : 'PUT' ,
280+ url : 'http://localhost:8378/1/sessions/me' ,
281+ headers : {
282+ 'X-Parse-Application-Id' : 'test' ,
283+ 'X-Parse-REST-API-Key' : 'rest' ,
284+ 'Content-Type' : 'application/json' ,
285+ } ,
286+ body : JSON . stringify ( { } ) ,
287+ } ) . catch ( e => e ) ;
288+ expect ( response . status ) . toBeGreaterThanOrEqual ( 400 ) ;
289+ expect ( response . status ) . toBeLessThan ( 500 ) ;
290+ expect ( response . data ?. code ) . toBeDefined ( ) ;
291+ } ) ;
292+ } ) ;
293+
294+ describe ( 'DELETE /sessions/me' , ( ) => {
295+ it ( 'should return error with invalid session token' , async ( ) => {
296+ const response = await request ( {
297+ method : 'DELETE' ,
298+ url : 'http://localhost:8378/1/sessions/me' ,
299+ headers : {
300+ 'X-Parse-Application-Id' : 'test' ,
301+ 'X-Parse-REST-API-Key' : 'rest' ,
302+ 'X-Parse-Session-Token' : 'r:invalid-session-token' ,
303+ } ,
304+ } ) . catch ( e => e ) ;
305+ expect ( response . status ) . not . toBe ( 500 ) ;
306+ expect ( response . data . code ) . toBe ( Parse . Error . INVALID_SESSION_TOKEN ) ;
307+ } ) ;
308+
309+ it ( 'should return error without session token' , async ( ) => {
310+ const response = await request ( {
311+ method : 'DELETE' ,
312+ url : 'http://localhost:8378/1/sessions/me' ,
313+ headers : {
314+ 'X-Parse-Application-Id' : 'test' ,
315+ 'X-Parse-REST-API-Key' : 'rest' ,
316+ } ,
317+ } ) . catch ( e => e ) ;
318+ expect ( response . status ) . toBeGreaterThanOrEqual ( 400 ) ;
319+ expect ( response . status ) . toBeLessThan ( 500 ) ;
320+ expect ( response . data ?. code ) . toBeDefined ( ) ;
321+ } ) ;
322+ } ) ;
259323} ) ;
0 commit comments