Skip to content

Commit d7f7042

Browse files
test: add unit test for MailtrapClient to ensure MailtrapError is thrown when testInboxId is missing in sandbox mode during batch sending
1 parent b72e941 commit d7f7042

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/__tests__/lib/mailtrap-client.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,31 @@ describe("lib/mailtrap-client: ", () => {
349349
});
350350

351351
describe("batch sending:", () => {
352+
it("throws MailtrapError(TEST_INBOX_ID_MISSING) when batch sending in sandbox mode without testInboxId", async () => {
353+
const client = new MailtrapClient({
354+
token: "MY_API_TOKEN",
355+
sandbox: true,
356+
accountId: 123,
357+
});
358+
359+
const batchData = {
360+
base: {
361+
from: { email: "a@b.com", name: "Sender" },
362+
subject: "Test",
363+
text: "Body",
364+
},
365+
requests: [
366+
{
367+
to: [{ email: "c@d.com" }],
368+
},
369+
],
370+
};
371+
372+
await expect(client.batchSend(batchData)).rejects.toEqual(
373+
new MailtrapError(TEST_INBOX_ID_MISSING)
374+
);
375+
});
376+
352377
it("rejects with Mailtrap error when bulk and sandbox modes are used together", async () => {
353378
const batchClient = new MailtrapClient({
354379
token: "MY_API_TOKEN",

0 commit comments

Comments
 (0)