import { test } from "node:test"; import assert from "node:assert/strict"; import { extractEmail } from "../src/commands/invites.ts"; test("extractEmail: pulls email from a posted request message", () => { const text = [ "New Slack invite request", "Name: Jane Doe", "Email: jane@example.com", "What brings you to devICT: community", "", "Approve by replying `@bot !invite` in this thread.", ].join("\n"); assert.equal(extractEmail(text), "jane@example.com"); }); test("extractEmail: returns undefined when no Email: line", () => { assert.equal(extractEmail("just some text\nno email here"), undefined); }); test("extractEmail: trims surrounding whitespace", () => { assert.equal(extractEmail("Email: spaced@example.com "), "spaced@example.com"); }); test("extractEmail: strips inline-code backticks", () => { assert.equal(extractEmail("Email: `tick@example.com`"), "tick@example.com"); }); test("extractEmail: unwraps Slack's mailto link format", () => { const text = "Name: Jane Doe\nEmail: \nWhat brings you: community"; assert.equal(extractEmail(text), "jane@example.com"); }); test("extractEmail: unwraps mailto link without display part", () => { const text = "Email: "; assert.equal(extractEmail(text), "sethetter+test@gmail.com"); });