@@ -4,63 +4,64 @@ import type { BaseNotificationBackend } from 'vintasend/dist/services/notificati
44import type { BaseEmailTemplateRenderer } from 'vintasend/dist/services/notification-template-renderers/base-email-template-renderer' ;
55import type { DatabaseNotification } from 'vintasend/dist/types/notification' ;
66import type { StoredAttachment , AttachmentFile } from 'vintasend/dist/types/attachment' ;
7+ import { vi , type Mocked } from 'vitest' ;
78import { NodemailerNotificationAdapterFactory } from '../index' ;
89
9- jest . mock ( 'nodemailer' ) ;
10+ vi . mock ( 'nodemailer' ) ;
1011
1112describe ( 'NodemailerNotificationAdapter - Attachments' , ( ) => {
1213 const mockTransporter = {
13- sendMail : jest . fn ( ) ,
14+ sendMail : vi . fn ( ) ,
1415 } ;
1516
1617 const mockTemplateRenderer = {
17- render : jest . fn ( ) ,
18- renderFromTemplateContent : jest . fn ( ) ,
18+ render : vi . fn ( ) ,
19+ renderFromTemplateContent : vi . fn ( ) ,
1920 // biome-ignore lint/suspicious/noExplicitAny: any just for testing
20- } as jest . Mocked < BaseEmailTemplateRenderer < any > > ;
21+ } as Mocked < BaseEmailTemplateRenderer < any > > ;
2122
2223 // biome-ignore lint/suspicious/noExplicitAny: any just for testing
23- const mockBackend : jest . Mocked < BaseNotificationBackend < any > > = {
24- persistNotification : jest . fn ( ) ,
25- persistNotificationUpdate : jest . fn ( ) ,
26- getAllFutureNotifications : jest . fn ( ) ,
27- getAllFutureNotificationsFromUser : jest . fn ( ) ,
28- getFutureNotificationsFromUser : jest . fn ( ) ,
29- getFutureNotifications : jest . fn ( ) ,
30- getAllPendingNotifications : jest . fn ( ) ,
31- getPendingNotifications : jest . fn ( ) ,
32- getNotification : jest . fn ( ) ,
33- markAsRead : jest . fn ( ) ,
34- filterAllInAppUnreadNotifications : jest . fn ( ) ,
35- cancelNotification : jest . fn ( ) ,
36- markAsSent : jest . fn ( ) ,
37- markAsFailed : jest . fn ( ) ,
38- storeAdapterAndContextUsed : jest . fn ( ) ,
39- getUserEmailFromNotification : jest . fn ( ) ,
40- filterInAppUnreadNotifications : jest . fn ( ) ,
41- bulkPersistNotifications : jest . fn ( ) ,
42- getAllNotifications : jest . fn ( ) ,
43- getNotifications : jest . fn ( ) ,
44- persistOneOffNotification : jest . fn ( ) ,
45- persistOneOffNotificationUpdate : jest . fn ( ) ,
46- getOneOffNotification : jest . fn ( ) ,
47- getAllOneOffNotifications : jest . fn ( ) ,
48- getOneOffNotifications : jest . fn ( ) ,
49- getAttachmentFile : jest . fn ( ) ,
50- deleteAttachmentFile : jest . fn ( ) ,
51- getOrphanedAttachmentFiles : jest . fn ( ) ,
52- getAttachments : jest . fn ( ) ,
53- deleteNotificationAttachment : jest . fn ( ) ,
54- findAttachmentFileByChecksum : jest . fn ( ) ,
55- filterNotifications : jest . fn ( ) ,
24+ const mockBackend : Mocked < BaseNotificationBackend < any > > = {
25+ persistNotification : vi . fn ( ) ,
26+ persistNotificationUpdate : vi . fn ( ) ,
27+ getAllFutureNotifications : vi . fn ( ) ,
28+ getAllFutureNotificationsFromUser : vi . fn ( ) ,
29+ getFutureNotificationsFromUser : vi . fn ( ) ,
30+ getFutureNotifications : vi . fn ( ) ,
31+ getAllPendingNotifications : vi . fn ( ) ,
32+ getPendingNotifications : vi . fn ( ) ,
33+ getNotification : vi . fn ( ) ,
34+ markAsRead : vi . fn ( ) ,
35+ filterAllInAppUnreadNotifications : vi . fn ( ) ,
36+ cancelNotification : vi . fn ( ) ,
37+ markAsSent : vi . fn ( ) ,
38+ markAsFailed : vi . fn ( ) ,
39+ storeAdapterAndContextUsed : vi . fn ( ) ,
40+ getUserEmailFromNotification : vi . fn ( ) ,
41+ filterInAppUnreadNotifications : vi . fn ( ) ,
42+ bulkPersistNotifications : vi . fn ( ) ,
43+ getAllNotifications : vi . fn ( ) ,
44+ getNotifications : vi . fn ( ) ,
45+ persistOneOffNotification : vi . fn ( ) ,
46+ persistOneOffNotificationUpdate : vi . fn ( ) ,
47+ getOneOffNotification : vi . fn ( ) ,
48+ getAllOneOffNotifications : vi . fn ( ) ,
49+ getOneOffNotifications : vi . fn ( ) ,
50+ getAttachmentFile : vi . fn ( ) ,
51+ deleteAttachmentFile : vi . fn ( ) ,
52+ getOrphanedAttachmentFiles : vi . fn ( ) ,
53+ getAttachments : vi . fn ( ) ,
54+ deleteNotificationAttachment : vi . fn ( ) ,
55+ findAttachmentFileByChecksum : vi . fn ( ) ,
56+ filterNotifications : vi . fn ( ) ,
5657 } ;
5758
5859 // biome-ignore lint/suspicious/noExplicitAny: any just for testing
5960 let mockNotification : DatabaseNotification < any > ;
6061
6162 beforeEach ( ( ) => {
62- jest . clearAllMocks ( ) ;
63- ( nodemailer . createTransport as jest . Mock ) . mockReturnValue ( mockTransporter ) ;
63+ vi . clearAllMocks ( ) ;
64+ vi . mocked ( nodemailer . createTransport ) . mockReturnValue ( mockTransporter as any ) ;
6465 mockNotification = {
6566 id : '123' ,
6667 notificationType : 'EMAIL' as const ,
@@ -109,10 +110,10 @@ describe('NodemailerNotificationAdapter - Attachments', () => {
109110
110111 const fileBuffer = Buffer . from ( 'test file content' ) ;
111112 const mockFile : AttachmentFile = {
112- read : jest . fn ( ) . mockResolvedValue ( fileBuffer ) ,
113- stream : jest . fn ( ) ,
114- url : jest . fn ( ) ,
115- delete : jest . fn ( ) ,
113+ read : vi . fn ( ) . mockResolvedValue ( fileBuffer ) ,
114+ stream : vi . fn ( ) ,
115+ url : vi . fn ( ) ,
116+ delete : vi . fn ( ) ,
116117 } ;
117118
118119 const attachment : StoredAttachment = {
@@ -173,17 +174,17 @@ describe('NodemailerNotificationAdapter - Attachments', () => {
173174 const fileBuffer2 = Buffer . from ( 'file 2 content' ) ;
174175
175176 const mockFile1 : AttachmentFile = {
176- read : jest . fn ( ) . mockResolvedValue ( fileBuffer1 ) ,
177- stream : jest . fn ( ) ,
178- url : jest . fn ( ) ,
179- delete : jest . fn ( ) ,
177+ read : vi . fn ( ) . mockResolvedValue ( fileBuffer1 ) ,
178+ stream : vi . fn ( ) ,
179+ url : vi . fn ( ) ,
180+ delete : vi . fn ( ) ,
180181 } ;
181182
182183 const mockFile2 : AttachmentFile = {
183- read : jest . fn ( ) . mockResolvedValue ( fileBuffer2 ) ,
184- stream : jest . fn ( ) ,
185- url : jest . fn ( ) ,
186- delete : jest . fn ( ) ,
184+ read : vi . fn ( ) . mockResolvedValue ( fileBuffer2 ) ,
185+ stream : vi . fn ( ) ,
186+ url : vi . fn ( ) ,
187+ delete : vi . fn ( ) ,
187188 } ;
188189
189190 const attachment1 : StoredAttachment = {
0 commit comments