Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
52 lines
1.9 KiB
Plaintext
52 lines
1.9 KiB
Plaintext
import { describe, beforeEach, it, expect, vitest } from 'vitest';
|
|
import nodemailer from 'nodemailer';
|
|
import { nodemailerAdapter } from './index.js';
|
|
const defaultArgs = {
|
|
defaultFromAddress: 'test@test.com',
|
|
defaultFromName: 'Test'
|
|
};
|
|
describe('email-nodemailer', ()=>{
|
|
describe('transport verification', ()=>{
|
|
let mockedVerify;
|
|
let mockTransport;
|
|
beforeEach(()=>{
|
|
mockedVerify = vitest.fn();
|
|
mockTransport = nodemailer.createTransport({
|
|
name: 'existing-transport',
|
|
// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-misused-promises
|
|
send: async (mail)=>{
|
|
// eslint-disable-next-line no-console
|
|
console.log('mock send', mail);
|
|
},
|
|
verify: mockedVerify,
|
|
version: '0.0.1'
|
|
});
|
|
});
|
|
it('should be invoked when skipVerify = false', async ()=>{
|
|
await nodemailerAdapter({
|
|
...defaultArgs,
|
|
skipVerify: false,
|
|
transport: mockTransport
|
|
});
|
|
expect(mockedVerify.mock.calls).toHaveLength(1);
|
|
});
|
|
it('should be invoked when skipVerify is undefined', async ()=>{
|
|
await nodemailerAdapter({
|
|
...defaultArgs,
|
|
skipVerify: false,
|
|
transport: mockTransport
|
|
});
|
|
expect(mockedVerify.mock.calls).toHaveLength(1);
|
|
});
|
|
it('should not be invoked when skipVerify = true', async ()=>{
|
|
await nodemailerAdapter({
|
|
...defaultArgs,
|
|
skipVerify: true,
|
|
transport: mockTransport
|
|
});
|
|
expect(mockedVerify.mock.calls).toHaveLength(0);
|
|
});
|
|
});
|
|
});
|
|
|
|
//# sourceMappingURL=plugin.spec.js.map |