@@ -3,10 +3,11 @@ import type { S3AttachmentManagerConfig } from '../aws-s3-attachment-manager';
33import { S3Client , PutObjectCommand , GetObjectCommand , DeleteObjectCommand } from '@aws-sdk/client-s3' ;
44import { getSignedUrl } from '@aws-sdk/s3-request-presigner' ;
55import { Readable } from 'node:stream' ;
6+ import { vi } from 'vitest' ;
67
78// Mock AWS SDK
8- jest . mock ( '@aws-sdk/client-s3' ) ;
9- jest . mock ( '@aws-sdk/s3-request-presigner' ) ;
9+ vi . mock ( '@aws-sdk/client-s3' ) ;
10+ vi . mock ( '@aws-sdk/s3-request-presigner' ) ;
1011
1112describe ( 'S3AttachmentManager' , ( ) => {
1213 let manager : S3AttachmentManager ;
@@ -18,15 +19,17 @@ describe('S3AttachmentManager', () => {
1819 } ;
1920
2021 beforeEach ( ( ) => {
21- jest . clearAllMocks ( ) ;
22+ vi . clearAllMocks ( ) ;
2223
2324 // Create mock S3Client
2425 mockS3Client = {
25- send : jest . fn ( ) ,
26+ send : vi . fn ( ) ,
2627 config : { region : 'us-east-1' } ,
2728 } ;
2829
29- ( S3Client as jest . MockedClass < typeof S3Client > ) . mockImplementation ( ( ) => mockS3Client ) ;
30+ vi . mocked ( S3Client ) . mockImplementation ( function ( ) {
31+ return mockS3Client as never ;
32+ } ) ;
3033
3134 manager = new S3AttachmentManager ( testConfig ) ;
3235 } ) ;
@@ -190,7 +193,7 @@ describe('S3AttachmentManager', () => {
190193
191194 it ( 'should handle file path string input' , async ( ) => {
192195 const fs = require ( 'node:fs/promises' ) ;
193- jest . spyOn ( fs , 'readFile' ) . mockResolvedValue ( Buffer . from ( 'file content' ) ) ;
196+ vi . spyOn ( fs , 'readFile' ) . mockResolvedValue ( Buffer . from ( 'file content' ) ) ;
194197
195198 mockS3Client . send . mockResolvedValueOnce ( { } as any ) ;
196199
@@ -328,7 +331,7 @@ describe('S3AttachmentManager', () => {
328331
329332 describe ( 'url' , ( ) => {
330333 it ( 'should generate presigned URL with default expiration' , async ( ) => {
331- ( getSignedUrl as jest . Mock ) . mockResolvedValue ( 'https://signed-url.example.com' ) ;
334+ vi . mocked ( getSignedUrl ) . mockResolvedValue ( 'https://signed-url.example.com' ) ;
332335
333336 const url = await attachmentFile . url ( ) ;
334337
@@ -341,7 +344,7 @@ describe('S3AttachmentManager', () => {
341344 } ) ;
342345
343346 it ( 'should generate presigned URL with custom expiration' , async ( ) => {
344- ( getSignedUrl as jest . Mock ) . mockResolvedValue ( 'https://signed-url.example.com' ) ;
347+ vi . mocked ( getSignedUrl ) . mockResolvedValue ( 'https://signed-url.example.com' ) ;
345348
346349 const url = await attachmentFile . url ( 7200 ) ;
347350
0 commit comments