File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -514,6 +514,9 @@ class ParseObject<T extends Attributes = Attributes> {
514514
515515 static _getRequestOptions ( options : RequestOptions & FullOptions & { json ?: boolean } = { } ) {
516516 const requestOptions : RequestOptions & FullOptions & { json ?: boolean } = { } ;
517+ if ( Object . prototype . toString . call ( options ) !== '[object Object]' ) {
518+ throw new Error ( 'request options must be of type Object' ) ;
519+ }
517520 const { hasOwn } = Object ;
518521 if ( hasOwn ( options , 'useMasterKey' ) ) {
519522 requestOptions . useMasterKey = ! ! options . useMasterKey ;
Original file line number Diff line number Diff line change @@ -356,4 +356,30 @@ describe('CloudController', () => {
356356 } ) ;
357357 expect ( options . useMasterKey ) . toBe ( false ) ;
358358 } ) ;
359+
360+ it ( 'run passes with empty options' , ( ) => {
361+ const values = [ undefined , { } ] ;
362+
363+ const mockRun = jest . fn ( ) ;
364+ mockRun . mockReturnValue ( Promise . resolve ( { result : { } } ) ) ;
365+
366+ CoreManager . setCloudController ( {
367+ run : mockRun ,
368+ getJobsData : jest . fn ( ) ,
369+ startJob : jest . fn ( ) ,
370+ } ) ;
371+
372+ for ( const value of values ) {
373+ mockRun . mockClear ( ) ;
374+ expect ( ( ) => Cloud . run ( 'myfunction' , { } , value ) ) . not . toThrow ( ) ;
375+ expect ( mockRun ) . toHaveBeenLastCalledWith ( 'myfunction' , { } , { } ) ;
376+ }
377+ } ) ;
378+
379+ it ( 'run throws with invalid options' , ( ) => {
380+ const values = [ null , [ ] ] ;
381+ for ( const value of values ) {
382+ expect ( ( ) => Cloud . run ( 'myfunction' , { } , value ) ) . toThrow ( ) ;
383+ }
384+ } ) ;
359385} ) ;
You can’t perform that action at this time.
0 commit comments