Something went wrong. Try again.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738import { 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: <mailto:jane@example.com|jane@example.com>\nWhat brings you: community"; assert.equal(extractEmail(text), "jane@example.com");});
test("extractEmail: unwraps mailto link without display part", () => { const text = "Email: <mailto:sethetter+test@gmail.com>"; assert.equal(extractEmail(text), "sethetter+test@gmail.com");});