File tree Expand file tree Collapse file tree 3 files changed +10
-22
lines changed Expand file tree Collapse file tree 3 files changed +10
-22
lines changed Original file line number Diff line number Diff line change @@ -552,12 +552,7 @@ describe('Parse Object', () => {
552552 expect ( ( ) => {
553553 item . set ( { 'foo^bar' : 'baz' } ) ;
554554 } ) . toThrow ( error ) ;
555- try {
556- await item . save ( { 'foo^bar' : 'baz' } ) ;
557- expect ( true ) . toBe ( false ) ;
558- } catch ( e ) {
559- expect ( e ) . toEqual ( error ) ;
560- }
555+ await expectAsync ( item . save ( { 'foo^bar' : 'baz' } ) ) . toBeRejectedWith ( error ) ;
561556 } ) ;
562557
563558 it ( 'cannot use invalid key names in multiple sets' , ( ) => {
Original file line number Diff line number Diff line change @@ -1357,7 +1357,7 @@ class ParseObject<T extends Attributes = Attributes> {
13571357 * @returns {Promise } A promise that is fulfilled when the save
13581358 * completes.
13591359 */
1360- save (
1360+ async save (
13611361 arg1 ?: undefined | string | { [ attr : string ] : any } | null ,
13621362 arg2 ?: SaveOptions | any ,
13631363 arg3 ?: SaveOptions
@@ -1403,9 +1403,8 @@ class ParseObject<T extends Attributes = Attributes> {
14031403 . then ( ( ) => controller . save ( unsavedObjects , saveOptions ) )
14041404 . then ( ( savedOjbects : this[ ] ) => savedOjbects . pop ( ) ) ;
14051405 }
1406- return controller . save ( unsaved , saveOptions ) . then ( ( ) => {
1407- return controller . save ( this , saveOptions ) ;
1408- } ) as Promise < ParseObject > as Promise < this> ;
1406+ await controller . save ( unsaved , saveOptions ) ;
1407+ return controller . save ( this , saveOptions ) as Promise < ParseObject > as Promise < this> ;
14091408 }
14101409
14111410 /**
Original file line number Diff line number Diff line change @@ -1951,12 +1951,9 @@ describe('ParseObject', () => {
19511951 const child = new ParseObject ( 'Item' ) ;
19521952 parent . set ( 'child' , child ) ;
19531953 child . set ( 'parent' , parent ) ;
1954- try {
1955- await parent . save ( ) ;
1956- expect ( true ) . toBe ( false ) ;
1957- } catch ( e ) {
1958- expect ( e . message ) . toBe ( 'Cannot create a pointer to an unsaved Object.' ) ;
1959- }
1954+ await expect ( parent . save ( ) ) . rejects . toThrowError (
1955+ 'Cannot create a pointer to an unsaved Object.'
1956+ ) ;
19601957 } ) ;
19611958
19621959 it ( 'will fail for deeper unsaved objects' , async ( ) => {
@@ -1965,12 +1962,9 @@ describe('ParseObject', () => {
19651962 const grandchild = new ParseObject ( 'Item' ) ;
19661963 parent . set ( 'child' , child ) ;
19671964 child . set ( 'child' , grandchild ) ;
1968- try {
1969- await parent . save ( ) ;
1970- expect ( true ) . toBe ( false ) ;
1971- } catch ( e ) {
1972- expect ( e . message ) . toBe ( 'Cannot create a pointer to an unsaved Object.' ) ;
1973- }
1965+ await expect ( parent . save ( ) ) . rejects . toThrowError (
1966+ 'Cannot create a pointer to an unsaved Object.'
1967+ ) ;
19741968 } ) ;
19751969
19761970 it ( 'does not mark shallow objects as dirty' , ( ) => {
You can’t perform that action at this time.
0 commit comments