Skip to content

Commit 0a115d3

Browse files
committed
Release vintasend-nodemailer@0.9.1
1 parent 9712817 commit 0a115d3

File tree

6 files changed

+160
-153
lines changed

6 files changed

+160
-153
lines changed

jest.config.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

package.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
{
22
"name": "vintasend-nodemailer",
3-
"version": "0.9.0",
3+
"version": "0.9.1",
44
"description": "",
55
"main": "dist/index.js",
66
"scripts": {
77
"build": "tsc",
88
"prepublishOnly": "npm run build",
9-
"test": "jest",
10-
"test:watch": "jest --watch",
11-
"test:coverage": "jest --coverage"
9+
"test": "vitest run",
10+
"test:watch": "vitest",
11+
"test:coverage": "vitest run --coverage"
1212
},
1313
"files": [
1414
"dist"
1515
],
1616
"author": "Hugo Bessa",
1717
"license": "MIT",
1818
"dependencies": {
19-
"nodemailer": "^7.0.13",
20-
"vintasend": "^0.9.0"
19+
"nodemailer": "^8.0.1",
20+
"vintasend": "^0.9.1"
2121
},
2222
"devDependencies": {
23-
"@types/jest": "^30.0.0",
2423
"@types/nodemailer": "^7.0.9",
25-
"jest": "^30.2.0",
26-
"ts-jest": "^29.4.6",
27-
"typescript": "^5.9.3"
24+
"@vitest/coverage-v8": "4.0.18",
25+
"typescript": "^5.9.3",
26+
"vitest": "4.0.18"
2827
}
2928
}

src/__tests__/nodemailer-adapter-attachments.test.ts

Lines changed: 53 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,64 @@ import type { BaseNotificationBackend } from 'vintasend/dist/services/notificati
44
import type { BaseEmailTemplateRenderer } from 'vintasend/dist/services/notification-template-renderers/base-email-template-renderer';
55
import type { DatabaseNotification } from 'vintasend/dist/types/notification';
66
import type { StoredAttachment, AttachmentFile } from 'vintasend/dist/types/attachment';
7+
import { vi, type Mocked } from 'vitest';
78
import { NodemailerNotificationAdapterFactory } from '../index';
89

9-
jest.mock('nodemailer');
10+
vi.mock('nodemailer');
1011

1112
describe('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 = {

src/__tests__/nodemailer-adapter-one-off.test.ts

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,57 @@ import type {
66
DatabaseNotification,
77
DatabaseOneOffNotification,
88
} from 'vintasend/dist/types/notification';
9+
import { vi, type Mocked } from 'vitest';
910
import type { NodemailerNotificationAdapter } from '../index';
1011
import { NodemailerNotificationAdapterFactory } from '../index';
1112

12-
jest.mock('nodemailer');
13+
vi.mock('nodemailer');
1314

1415
describe('NodemailerNotificationAdapter - One-Off Notifications', () => {
1516
const mockTransporter = {
16-
sendMail: jest.fn(),
17+
sendMail: vi.fn(),
1718
};
1819

1920
const mockTemplateRenderer = {
20-
render: jest.fn(),
21-
renderFromTemplateContent: jest.fn(),
21+
render: vi.fn(),
22+
renderFromTemplateContent: vi.fn(),
2223
// biome-ignore lint/suspicious/noExplicitAny: any just for testing
23-
} as jest.Mocked<BaseEmailTemplateRenderer<any>>;
24+
} as Mocked<BaseEmailTemplateRenderer<any>>;
2425

2526
// biome-ignore lint/suspicious/noExplicitAny: any just for testing
26-
const mockBackend: jest.Mocked<BaseNotificationBackend<any>> = {
27-
persistNotification: jest.fn(),
28-
persistNotificationUpdate: jest.fn(),
29-
getAllFutureNotifications: jest.fn(),
30-
getAllFutureNotificationsFromUser: jest.fn(),
31-
getFutureNotificationsFromUser: jest.fn(),
32-
getFutureNotifications: jest.fn(),
33-
getAllPendingNotifications: jest.fn(),
34-
getPendingNotifications: jest.fn(),
35-
getNotification: jest.fn(),
36-
markAsRead: jest.fn(),
37-
filterAllInAppUnreadNotifications: jest.fn(),
38-
cancelNotification: jest.fn(),
39-
markAsSent: jest.fn(),
40-
markAsFailed: jest.fn(),
41-
storeAdapterAndContextUsed: jest.fn(),
42-
getUserEmailFromNotification: jest.fn(),
43-
filterInAppUnreadNotifications: jest.fn(),
44-
bulkPersistNotifications: jest.fn(),
45-
getAllNotifications: jest.fn(),
46-
getNotifications: jest.fn(),
47-
persistOneOffNotification: jest.fn(),
48-
persistOneOffNotificationUpdate: jest.fn(),
49-
getOneOffNotification: jest.fn(),
50-
getAllOneOffNotifications: jest.fn(),
51-
getOneOffNotifications: jest.fn(),
52-
getAttachmentFile: jest.fn(),
53-
deleteAttachmentFile: jest.fn(),
54-
getOrphanedAttachmentFiles: jest.fn(),
55-
getAttachments: jest.fn(),
56-
deleteNotificationAttachment: jest.fn(),
57-
findAttachmentFileByChecksum: jest.fn(),
58-
filterNotifications: jest.fn(),
27+
const mockBackend: Mocked<BaseNotificationBackend<any>> = {
28+
persistNotification: vi.fn(),
29+
persistNotificationUpdate: vi.fn(),
30+
getAllFutureNotifications: vi.fn(),
31+
getAllFutureNotificationsFromUser: vi.fn(),
32+
getFutureNotificationsFromUser: vi.fn(),
33+
getFutureNotifications: vi.fn(),
34+
getAllPendingNotifications: vi.fn(),
35+
getPendingNotifications: vi.fn(),
36+
getNotification: vi.fn(),
37+
markAsRead: vi.fn(),
38+
filterAllInAppUnreadNotifications: vi.fn(),
39+
cancelNotification: vi.fn(),
40+
markAsSent: vi.fn(),
41+
markAsFailed: vi.fn(),
42+
storeAdapterAndContextUsed: vi.fn(),
43+
getUserEmailFromNotification: vi.fn(),
44+
filterInAppUnreadNotifications: vi.fn(),
45+
bulkPersistNotifications: vi.fn(),
46+
getAllNotifications: vi.fn(),
47+
getNotifications: vi.fn(),
48+
persistOneOffNotification: vi.fn(),
49+
persistOneOffNotificationUpdate: vi.fn(),
50+
getOneOffNotification: vi.fn(),
51+
getAllOneOffNotifications: vi.fn(),
52+
getOneOffNotifications: vi.fn(),
53+
getAttachmentFile: vi.fn(),
54+
deleteAttachmentFile: vi.fn(),
55+
getOrphanedAttachmentFiles: vi.fn(),
56+
getAttachments: vi.fn(),
57+
deleteNotificationAttachment: vi.fn(),
58+
findAttachmentFileByChecksum: vi.fn(),
59+
filterNotifications: vi.fn(),
5960
};
6061

6162
// biome-ignore lint/suspicious/noExplicitAny: any just for testing
@@ -66,8 +67,8 @@ describe('NodemailerNotificationAdapter - One-Off Notifications', () => {
6667
let adapter: NodemailerNotificationAdapter<typeof mockTemplateRenderer, any>;
6768

6869
beforeEach(() => {
69-
jest.clearAllMocks();
70-
(nodemailer.createTransport as jest.Mock).mockReturnValue(mockTransporter);
70+
vi.clearAllMocks();
71+
vi.mocked(nodemailer.createTransport).mockReturnValue(mockTransporter as any);
7172

7273
// Reset the sendMail mock to resolve successfully by default
7374
mockTransporter.sendMail.mockResolvedValue({
@@ -247,7 +248,7 @@ describe('NodemailerNotificationAdapter - One-Off Notifications', () => {
247248
html: '<p>Test Body</p>',
248249
});
249250

250-
jest.clearAllMocks();
251+
vi.clearAllMocks();
251252
mockTemplateRenderer.render.mockResolvedValue({
252253
subject: 'Test Subject 2',
253254
body: '<p>Test Body 2</p>',

0 commit comments

Comments
 (0)