@@ -3,6 +3,7 @@ import axios, { AxiosError } from 'axios';
33
44jest . mock ( 'axios' , ( ) => ( {
55 isAxiosError : jest . fn ( ) ,
6+ get : jest . fn ( ) ,
67} ) ) ;
78
89const mockedAxios = axios as jest . Mocked < typeof axios > ;
@@ -345,34 +346,7 @@ describe('common utility functions', () => {
345346
346347 it ( 'should handle generic Error objects' , ( ) => {
347348 const error = new Error ( 'Something went wrong' ) ;
348- error . name = 'ValidationError' ;
349-
350- mockedAxios . isAxiosError . mockReturnValue ( false ) ;
351-
352- const result = getFormattedError ( error ) ;
353-
354- expect ( result ) . toEqual ( {
355- title : 'ValidationError' ,
356- message : 'Something went wrong' ,
357- } ) ;
358- } ) ;
359-
360- it ( 'should return error object input' , ( ) => {
361- const result = getFormattedError ( {
362- message : 'An unknown error' ,
363- } ) ;
364- expect ( result ) . toEqual ( {
365- title : 'Error' ,
366- message : 'An unknown error occurred' ,
367- } ) ;
368- } ) ;
369-
370- it ( 'should handle generic Error objects without name' , ( ) => {
371- const error = new Error ( 'Something went wrong' ) ;
372- error . name = undefined ; // Set name to undefined for this test
373-
374- mockedAxios . isAxiosError . mockReturnValue ( false ) ;
375-
349+ mockedAxios . get . mockRejectedValue ( error ) ;
376350 const result = getFormattedError ( error ) ;
377351
378352 expect ( result ) . toEqual ( {
0 commit comments