import { describe, it, expect } from "bun:test"; import { plunkEmail } from "./plunk"; const ALL_TESTS = !!process.env.ALL_TESTS; describe.skipIf(ALL_TESTS)("plunk", () => { it("should throw on failed", async () => { const driver = plunkEmail({ apiKey: "invalid" }); expect(driver.send("foo@bar.com", "Test", "Test")).rejects.toThrow(); }); it("should send an email", async () => { const driver = plunkEmail({ apiKey: process.env.PLUNK_API_KEY!, from: undefined, // Default to what Plunk sets }); const response = await driver.send( "help@bknd.io", "Test Email from Plunk", "This is a test email", ); expect(response).toBeDefined(); expect(response.success).toBe(true); expect(response.emails).toBeDefined(); expect(response.timestamp).toBeDefined(); }); it("should send HTML email", async () => { const driver = plunkEmail({ apiKey: process.env.PLUNK_API_KEY!, from: undefined, }); const htmlBody = "

Test Email

This is a test email

"; const response = await driver.send( "help@bknd.io", "HTML Test", htmlBody, ); expect(response).toBeDefined(); expect(response.success).toBe(true); }); it("should send with text and html", async () => { const driver = plunkEmail({ apiKey: process.env.PLUNK_API_KEY!, from: undefined, }); const response = await driver.send("test@example.com", "Test Email", { text: "help@bknd.io", html: "

This is HTML

", }); expect(response).toBeDefined(); expect(response.success).toBe(true); }); });