Files
ihasmail/web/src/lib/__tests__/address.test.ts
T
jcoffey-dev c17887e48e ihasmail 2.0: rebuild as Stalwart-first JMAP webmail
Replace the FastAPI/HTMX prototype with a Node/Hono session proxy and a
React 19/Vite SPA. Mail (conversation view, search operators, labels,
sanitised HTML, privacy image proxy, invites, undo send, templates),
calendar (month/week/day/agenda, invites, free/busy, categories,
context menus), contacts (JSContact, groups, vCard), files, Sieve filter
builder (incl. filter-from-message with retroactive apply), vacation,
identities with default + Reply-To, PWA/mobile layout, push via SSE,
in-memory mock Stalwart for dev, Docker + CI.
2026-08-23 01:07:13 -07:00

24 lines
1.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { formatAddress, initials, isValidEmail, parseAddressList } from "../address";
describe("address parsing", () => {
it("parses mixed lists", () => {
const list = parseAddressList('Ann Example <[email protected]>, [email protected]; "Smith, John" <[email protected]>');
expect(list).toEqual([
{ name: "Ann Example", email: "[email protected]" },
{ name: null, email: "[email protected]" },
{ name: "Smith, John", email: "[email protected]" },
]);
});
it("formats with quoting when needed", () => {
expect(formatAddress({ name: "Smith, John", email: "[email protected]" })).toBe('"Smith, John" <[email protected]>');
expect(formatAddress({ name: null, email: "[email protected]" })).toBe("[email protected]");
});
it("validates and initials", () => {
expect(isValidEmail("[email protected]")).toBe(true);
expect(isValidEmail("nope")).toBe(false);
expect(initials({ name: "Grace Hopper", email: "" })).toBe("GH");
expect(initials({ name: null, email: "[email protected]" })).toBe("LK");
});
});