mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-15 08:56:47 +02:00
add check for what email data was passed to nodemailer
This commit is contained in:
parent
bfff6d0207
commit
27ce95daf8
1 changed files with 15 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
||||||
jest.mock("nodemailer", () => ({
|
jest.mock("nodemailer", () => ({
|
||||||
createTransport: jest.fn(),
|
createTransport: jest.fn(),
|
||||||
}));
|
}));
|
||||||
const mockNodEmailer = require("nodemailer");
|
const mockNodeMailer = require("nodemailer");
|
||||||
|
|
||||||
const SMTP = require("./smtp");
|
const SMTP = require("./smtp");
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ describe("notification to act properly on send", () => {
|
||||||
.mockResolvedValue(() => {
|
.mockResolvedValue(() => {
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
mockNodEmailer.createTransport.mockImplementationOnce(() => {
|
mockNodeMailer.createTransport.mockImplementationOnce(() => {
|
||||||
return { sendMail: sender };
|
return { sendMail: sender };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -31,12 +31,12 @@ describe("notification to act properly on send", () => {
|
||||||
smtpPassword: "password",
|
smtpPassword: "password",
|
||||||
customSubject: "custom subject",
|
customSubject: "custom subject",
|
||||||
};
|
};
|
||||||
let msg = "Message";
|
let msg = "PassedInMessage";
|
||||||
let monitorConf = { };
|
let monitorConf = { };
|
||||||
let heartbeatConf = { };
|
let heartbeatConf = { };
|
||||||
let res = await notif.send(notificationConf, msg, monitorConf, heartbeatConf);
|
let res = await notif.send(notificationConf, msg, monitorConf, heartbeatConf);
|
||||||
|
|
||||||
expect(mockNodEmailer.createTransport).toHaveBeenCalledWith({
|
expect(mockNodeMailer.createTransport).toHaveBeenCalledWith({
|
||||||
auth: {
|
auth: {
|
||||||
pass: "password",
|
pass: "password",
|
||||||
user: "username",
|
user: "username",
|
||||||
|
@ -46,5 +46,16 @@ describe("notification to act properly on send", () => {
|
||||||
secure: "secure",
|
secure: "secure",
|
||||||
});
|
});
|
||||||
expect(res).toBe("Sent Successfully.");
|
expect(res).toBe("Sent Successfully.");
|
||||||
|
expect(sender).toHaveBeenCalledWith({
|
||||||
|
bcc: undefined,
|
||||||
|
cc: undefined,
|
||||||
|
from: undefined,
|
||||||
|
subject: "custom subject",
|
||||||
|
text: "PassedInMessage\nTime (UTC): undefined",
|
||||||
|
tls: {
|
||||||
|
rejectUnauthorized: false,
|
||||||
|
},
|
||||||
|
to: undefined,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue