feat(marketing-pages): RecordingMailerService
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
import { describe, it, expect } from "vitest";
|
||||||
|
import { RecordingMailerService } from "@/infrastructure/services/recording-mailer.service";
|
||||||
|
|
||||||
|
describe("RecordingMailerService", () => {
|
||||||
|
it("records welcome calls", async () => {
|
||||||
|
const mailer = new RecordingMailerService();
|
||||||
|
await mailer.sendWelcome("u1", "u1@example.com");
|
||||||
|
expect(mailer.sent).toEqual([{ userId: "u1", email: "u1@example.com" }]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("preserves call order across multiple sends", async () => {
|
||||||
|
const mailer = new RecordingMailerService();
|
||||||
|
await mailer.sendWelcome("u1", "a@x");
|
||||||
|
await mailer.sendWelcome("u2", "b@x");
|
||||||
|
expect(mailer.sent).toEqual([
|
||||||
|
{ userId: "u1", email: "a@x" },
|
||||||
|
{ userId: "u2", email: "b@x" },
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import type { IMailerService } from "../../application/services/mailer.service.interface";
|
||||||
|
|
||||||
|
export class RecordingMailerService implements IMailerService {
|
||||||
|
readonly sent: { userId: string; email: string }[] = [];
|
||||||
|
|
||||||
|
async sendWelcome(userId: string, email: string): Promise<void> {
|
||||||
|
this.sent.push({ userId, email });
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user