File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -829,14 +829,16 @@ describe('SongService', () => {
829829
830830 jest
831831 . spyOn ( fileService , 'getSongDownloadUrl' )
832- . mockRejectedValue ( new Error ( ) ) ;
832+ . mockImplementationOnce ( ( ) => {
833+ throw new Error ( 'Internal error' ) ;
834+ } ) ;
833835
834836 await expect ( service . getSongDownloadUrl ( publicId , user ) ) . rejects . toThrow (
835837 HttpException ,
836838 ) ;
837839 } ) ;
838840
839- it ( 'should throw an error in case of an internal error on saveing the song' , async ( ) => {
841+ it ( 'should throw an error in case of an internal error on saving the song' , async ( ) => {
840842 const publicId = 'test-id' ;
841843 const user : UserDocument = { _id : 'test-user-id' } as UserDocument ;
842844
@@ -863,7 +865,9 @@ describe('SongService', () => {
863865 packedSongUrl : 'http://test.com/packed-file.nbs' ,
864866 nbsFileUrl : 'http://test.com/file.nbs' ,
865867 thumbnailUrl : 'http://test.com/thumbnail.nbs' ,
866- save : jest . fn ( ) . mockRejectedValue ( new Error ( ) ) , // Simulate error on save
868+ save : jest . fn ( ) . mockImplementationOnce ( ( ) => {
869+ throw new Error ( 'Error saving song' ) ;
870+ } ) ,
867871 } ;
868872
869873 jest . spyOn ( songModel , 'findOne' ) . mockResolvedValue ( songEntity ) ;
You can’t perform that action at this time.
0 commit comments