mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-04-07 14:04:35 +08:00
[feature] Notification service added
This commit is contained in:
@ -1,20 +1,19 @@
|
||||
const { describe, test, expect, afterAll} = require('@jest/globals');
|
||||
const { describe, test, expect, afterAll } = require('@jest/globals');
|
||||
const nodemailer = require('../../Common/node_modules/nodemailer');
|
||||
|
||||
const mailService = require('../../Common/sources/mailService');
|
||||
const operationContext = require('../../Common/sources/operationContext');
|
||||
|
||||
const ctx = new operationContext.Context();
|
||||
const defaultTestSMTPServer = {
|
||||
host: 'smtp.ethereal.email',
|
||||
port: 587
|
||||
};
|
||||
const testTimeout = 1000 * 10;
|
||||
|
||||
afterAll(function () {
|
||||
mailService.transportersRelease();
|
||||
})
|
||||
|
||||
describe('Mail service', function () {
|
||||
console.log('!!!!!!!!!!!!!!!!', global.dev);
|
||||
describe('SMTP', function () {
|
||||
const { host, port } = defaultTestSMTPServer;
|
||||
|
||||
@ -23,7 +22,7 @@ describe('Mail service', function () {
|
||||
// Ethereial is a special SMTP sever for mailing tests in collaboration with Nodemailer.
|
||||
const accounts = await Promise.all([nodemailer.createTestAccount(), nodemailer.createTestAccount(), nodemailer.createTestAccount()]);
|
||||
const auth = accounts.map(account => { return { user: account.user, pass: account.pass }});
|
||||
auth.forEach(credential => mailService.createTransporter(ctx, host, port, credential, { from: 'some.mail@ethereal.com' }));
|
||||
auth.forEach(credential => mailService.createTransporter(host, port, credential, { from: 'some.mail@ethereal.com' }));
|
||||
|
||||
for (let i = 0; i < auth.length; i++) {
|
||||
const credentials = auth[i];
|
||||
@ -37,7 +36,7 @@ describe('Mail service', function () {
|
||||
}
|
||||
|
||||
const accountToBeDeleted = auth[1];
|
||||
mailService.deleteTransporter(ctx, host, accountToBeDeleted.user);
|
||||
mailService.deleteTransporter(host, accountToBeDeleted.user);
|
||||
|
||||
const errorPromise = mailService.send(
|
||||
host,
|
||||
@ -46,6 +45,6 @@ describe('Mail service', function () {
|
||||
);
|
||||
|
||||
await expect(errorPromise).rejects.toEqual(`MailService: no transporter exists for host "${host}" and user "${accountToBeDeleted.user}"`);
|
||||
});
|
||||
}, testTimeout);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user