12 lines · 699 BRaw
| 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; |
| 3 | import { compose, invited } from "../mail.ts"; |
| 4 | |
| 5 | test("an email has a text and an escaped HTML body with its link", () => { |
| 6 | const message = compose("noreply@useref.dev", invited("eve@example.com", "<acme>", "Aman", "https://useref.dev/invite/abc")); |
| 7 | assert.equal(message.to, "eve@example.com"); |
| 8 | assert.deepEqual(message.from, { email: "noreply@useref.dev", name: "refs" }); |
| 9 | assert.match(message.text!, /^Join <acme>: https:\/\/useref\.dev\/invite\/abc$/m); |
| 10 | assert.match(message.html!, /<a href="https:\/\/useref\.dev\/invite\/abc" [^>]*>Join <acme><\/a>/); |
| 11 | assert.doesNotMatch(message.html!, /<acme>/); |
| 12 | }); |