All files / test dataProvider.ts

100% Statements 14/14
100% Branches 0/0
100% Functions 2/2
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 451x 1x     1x 1x 1x   1x   1x                                     1x 1x           1x 1x   1x     1x    
import { appInstall, DEFAULT_USER } from '@orchesty/nodejs-connectors/test/DataProvider';
import {
    container, db,
} from '@orchesty/nodejs-connectors/test/TestAbstract';
import CoreFormsEnum from '@orchesty/nodejs-sdk/dist/lib/Application/Base/CoreFormsEnum';
import SmtpSendEmail from '../src/Connector/SmtpSendEmail';
import SmtpApplication, { CONNECTION_URL, NAME } from '../src/SmtpApplication';
 
export const connectionUrl = 'smtps://username:password@smtp.example.com/?pool=true';
 
jest.mock('nodemailer', (): unknown => ({
    createTransport: jest.fn().mockReturnValue({
        sendMail: jest.fn().mockReturnValue({
            accepted: ['neco@gmail.com'],
            envelope: {
                from: 'neco@neco.com',
                to: ['neco@gmail.com'],
            },
            envelopeTime: 2,
            messageId: '<731836a2-74d2-36f6-8053-08242c91ce1c@neco.com>',
            messageSize: 614,
            messageTime: 3,
            rejected: [],
            response:
            '250 Ok: queued as uDtelNMtPWAML6YfHjji5zYLhJjL1frJBtBBOZNJIcE=@mailhog.example',
        }),
    }),
}));
 
export default function init(): void {
    appInstall(NAME, DEFAULT_USER, {
        [CoreFormsEnum.AUTHORIZATION_FORM]: {
            [CONNECTION_URL]: connectionUrl,
        },
    });
 
    const app = new SmtpApplication();
    container.setApplication(app);
 
    const sendEmail = new SmtpSendEmail()
        .setDb(db)
        .setApplication(app);
    container.setConnector(sendEmail);
}