Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,53 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
vi.mock("~/utils/db/appConfiguration.db.server", () => ({
|
||||
getAppConfiguration: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("./MailjetEmailService", () => ({
|
||||
sendEmailMailjet: vi.fn(async () => ({ provider: "queue", status: "queued", messageId: "job_1" })),
|
||||
}));
|
||||
|
||||
import { getAppConfiguration } from "~/utils/db/appConfiguration.db.server";
|
||||
import { sendEmailMailjet } from "./MailjetEmailService";
|
||||
import { sendEmail } from "./EmailService";
|
||||
|
||||
const getAppConfigurationMock = vi.mocked(getAppConfiguration);
|
||||
const sendEmailMailjetMock = vi.mocked(sendEmailMailjet);
|
||||
|
||||
describe("EmailService queued delivery", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
delete process.env.MAILJET_API_KEY;
|
||||
delete process.env.MAILJET_FROM_EMAIL;
|
||||
getAppConfigurationMock.mockResolvedValue({
|
||||
email: {
|
||||
provider: "mailjet",
|
||||
fromEmail: "",
|
||||
fromName: "",
|
||||
supportEmail: "",
|
||||
},
|
||||
} as Awaited<ReturnType<typeof getAppConfiguration>>);
|
||||
});
|
||||
|
||||
it("queues mail without requiring Mailjet credentials in the web runtime", async () => {
|
||||
await sendEmail({
|
||||
request: new Request("https://admin.example.com/settings/transactional-emails"),
|
||||
to: "ada@example.com",
|
||||
subject: "Welcome",
|
||||
body: "<p>Hello</p>",
|
||||
alias: "registration-welcome",
|
||||
data: { firstName: "Ada" },
|
||||
});
|
||||
|
||||
expect(sendEmailMailjetMock).toHaveBeenCalledWith({
|
||||
data: {
|
||||
to: "ada@example.com",
|
||||
subject: "Welcome",
|
||||
body: "<p>Hello</p>",
|
||||
alias: "registration-welcome",
|
||||
data: { firstName: "Ada" },
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user