@@ -256,4 +256,64 @@ 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 ) . not . toBe ( 500 ) ;
289+ } ) ;
290+ } ) ;
291+
292+ describe ( 'DELETE /sessions/me' , ( ) => {
293+ it ( 'should return error with invalid session token' , async ( ) => {
294+ const response = await request ( {
295+ method : 'DELETE' ,
296+ url : 'http://localhost:8378/1/sessions/me' ,
297+ headers : {
298+ 'X-Parse-Application-Id' : 'test' ,
299+ 'X-Parse-REST-API-Key' : 'rest' ,
300+ 'X-Parse-Session-Token' : 'r:invalid-session-token' ,
301+ } ,
302+ } ) . catch ( e => e ) ;
303+ expect ( response . status ) . not . toBe ( 500 ) ;
304+ expect ( response . data . code ) . toBe ( Parse . Error . INVALID_SESSION_TOKEN ) ;
305+ } ) ;
306+
307+ it ( 'should return error without session token' , async ( ) => {
308+ const response = await request ( {
309+ method : 'DELETE' ,
310+ url : 'http://localhost:8378/1/sessions/me' ,
311+ headers : {
312+ 'X-Parse-Application-Id' : 'test' ,
313+ 'X-Parse-REST-API-Key' : 'rest' ,
314+ } ,
315+ } ) . catch ( e => e ) ;
316+ expect ( response . status ) . not . toBe ( 500 ) ;
317+ } ) ;
318+ } ) ;
259319} ) ;
0 commit comments