@@ -3,17 +3,15 @@ import app from "@src/app";
33import { tryber } from "@src/features/database" ;
44import { getPresignedUrl } from "@src/features/s3/presignUrl" ;
55
6- jest . mock ( "@src/features/s3/presignUrl" ) ;
7-
8- const mockedGetPresignedUrl = getPresignedUrl as jest . MockedFunction <
9- typeof getPresignedUrl
10- > ;
6+ jest . mock ( "@src/features/s3/presignUrl" , ( ) => {
7+ return {
8+ getPresignedUrl : jest
9+ . fn ( )
10+ . mockImplementation ( ( url : string ) => Promise . resolve ( url ) ) ,
11+ } ;
12+ } ) ;
1113
1214describe ( "GET /campaigns/campaignId/finance/otherCosts" , ( ) => {
13- beforeEach ( ( ) => {
14- mockedGetPresignedUrl . mockImplementation ( async ( url : string ) => url ) ;
15- } ) ;
16-
1715 afterEach ( ( ) => {
1816 jest . clearAllMocks ( ) ;
1917 } ) ;
@@ -347,21 +345,21 @@ describe("GET /campaigns/campaignId/finance/otherCosts", () => {
347345 expect ( costWithoutAttachments . attachments ) . toEqual ( [ ] ) ;
348346 } ) ;
349347
350- it ( "Should call getPresignedUrl for each attachment with 3 hours expiration " , async ( ) => {
348+ it ( "Should call getPresignedUrl for each attachment" , async ( ) => {
351349 await request ( app )
352350 . get ( "/campaigns/1/finance/otherCosts" )
353351 . set ( "Authorization" , "Bearer admin" ) ;
354352
355- expect ( mockedGetPresignedUrl ) . toHaveBeenCalledTimes ( 3 ) ;
356- expect ( mockedGetPresignedUrl ) . toHaveBeenCalledWith (
353+ expect ( getPresignedUrl ) . toHaveBeenCalledTimes ( 3 ) ;
354+ expect ( getPresignedUrl ) . toHaveBeenCalledWith (
357355 "https://example.com/attachment1.pdf" ,
358356 10800
359357 ) ;
360- expect ( mockedGetPresignedUrl ) . toHaveBeenCalledWith (
358+ expect ( getPresignedUrl ) . toHaveBeenCalledWith (
361359 "https://example.com/attachment2.jpg" ,
362360 10800
363361 ) ;
364- expect ( mockedGetPresignedUrl ) . toHaveBeenCalledWith (
362+ expect ( getPresignedUrl ) . toHaveBeenCalledWith (
365363 "https://example.com/attachment3.png" ,
366364 10800
367365 ) ;
0 commit comments