File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -626,12 +626,14 @@ describe('SongService', () => {
626626 file : 'somebytes' ,
627627 allowDownload : false ,
628628 uploader : { } ,
629+ save : jest . fn ( ) ,
629630 } as any ;
630631
631632 songDocument . save = jest . fn ( ) . mockResolvedValue ( songDocument ) ;
632633
633634 const mockFindOne = {
634635 populate : jest . fn ( ) . mockResolvedValue ( songDocument ) ,
636+ ...songDocument ,
635637 } ;
636638
637639 jest . spyOn ( songModel , 'findOne' ) . mockReturnValue ( mockFindOne as any ) ;
@@ -677,15 +679,14 @@ describe('SongService', () => {
677679 const publicId = 'test-id' ;
678680 const user : UserDocument = null as any ;
679681
680- jest . spyOn ( songModel , 'findOne' ) . mockReturnValue ( {
681- populate : jest . fn ( ) . mockImplementationOnce ( ( ) => {
682- throw new HttpException ( 'Song not found' , 404 ) ;
683- } ) ,
684- } as any ) ;
682+ const songEntity = {
683+ publicId : 'test-public-id' ,
684+ visibility : 'private' ,
685+ uploader : 'different-user-id' ,
686+ } ;
685687
686- await expect ( service . getSong ( publicId , user ) ) . rejects . toThrow (
687- HttpException ,
688- ) ;
688+ jest . spyOn ( songModel , 'findOne' ) . mockReturnValue ( songEntity as any ) ;
689+ expect ( service . getSong ( publicId , user ) ) . rejects . toThrow ( HttpException ) ;
689690 } ) ;
690691 } ) ;
691692
You can’t perform that action at this time.
0 commit comments