ci(app): testing and other app config changes
This commit is contained in:
42
tests/sendEmail.test.ts
Normal file
42
tests/sendEmail.test.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
import { sendEmail } from "../backend/src/utils/sendEmail.utils";
|
||||
|
||||
// Mock the logger before imports
|
||||
vi.mock("../backend/src/logger/logger.controller", () => ({
|
||||
createLogger: () => ({
|
||||
info: vi.fn(),
|
||||
error: vi.fn(),
|
||||
debug: vi.fn(),
|
||||
fatal: vi.fn(),
|
||||
}),
|
||||
}));
|
||||
|
||||
describe("Mail sending", () => {
|
||||
test("should send an email successfully", async () => {
|
||||
const result = await sendEmail({
|
||||
email: "blake.matthes@alpla.com",
|
||||
subject: "LST - Testing system",
|
||||
template: "testEmail",
|
||||
context: { name: "blake" },
|
||||
});
|
||||
|
||||
expect(result).toMatchObject({
|
||||
success: true,
|
||||
});
|
||||
|
||||
expect(result?.message).toContain("blake.matthes@alpla.com");
|
||||
});
|
||||
|
||||
test("should handle email send failure gracefully", async () => {
|
||||
const badResult = await sendEmail({
|
||||
email: "invalid-address",
|
||||
subject: "LST - Testing system",
|
||||
template: "",
|
||||
context: {},
|
||||
});
|
||||
|
||||
expect(badResult).toMatchObject({
|
||||
success: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user