34 lines
758 B
TypeScript
34 lines
758 B
TypeScript
import { beforeEach, expect, test, vi } from "vitest";
|
|
|
|
const { sendMail } = vi.hoisted(() => ({
|
|
sendMail: vi.fn().mockResolvedValue({ messageId: "message-1" }),
|
|
}));
|
|
|
|
vi.mock("nodemailer", () => ({
|
|
default: {
|
|
createTransport: () => ({ sendMail }),
|
|
},
|
|
}));
|
|
|
|
import { emailService } from "./service";
|
|
|
|
beforeEach(() => {
|
|
sendMail.mockClear();
|
|
});
|
|
|
|
test("links new-album notifications to the existing sign-in page", async () => {
|
|
await emailService.sendNewAlbumNotification(
|
|
"redaktion@example.com",
|
|
"Spieltag 1",
|
|
);
|
|
|
|
expect(sendMail).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
to: "redaktion@example.com",
|
|
html: expect.stringContaining(
|
|
'href="http://localhost:3000/anmelden"',
|
|
),
|
|
}),
|
|
);
|
|
});
|