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', () => {
626
626
file : 'somebytes' ,
627
627
allowDownload : false ,
628
628
uploader : { } ,
629
+ save : jest . fn ( ) ,
629
630
} as any ;
630
631
631
632
songDocument . save = jest . fn ( ) . mockResolvedValue ( songDocument ) ;
632
633
633
634
const mockFindOne = {
634
635
populate : jest . fn ( ) . mockResolvedValue ( songDocument ) ,
636
+ ...songDocument ,
635
637
} ;
636
638
637
639
jest . spyOn ( songModel , 'findOne' ) . mockReturnValue ( mockFindOne as any ) ;
@@ -677,15 +679,14 @@ describe('SongService', () => {
677
679
const publicId = 'test-id' ;
678
680
const user : UserDocument = null as any ;
679
681
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
+ } ;
685
687
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 ) ;
689
690
} ) ;
690
691
} ) ;
691
692
You can’t perform that action at this time.
0 commit comments