import type { EmailMessage } from "../types.mjs"; /** A partial message shape used in assertions. Each field is loose: * strings and RegExps are both accepted for `subject` / `text` / `html`, * and `to`/`from`/`cc`/`bcc` match any supplied address. */ export interface EmailMatch { from?: string | RegExp; to?: string | RegExp; cc?: string | RegExp; bcc?: string | RegExp; subject?: string | RegExp; text?: string | RegExp; html?: string | RegExp; stream?: string; } /** Check whether `actual` satisfies all fields declared in `expected`. */ export declare function matchesEmail(actual: EmailMessage, expected: EmailMatch): { pass: boolean; diff: string | null; }; /** Vitest-compatible matchers: register from a test setup file. * * ```ts * import { expect } from "vitest" * import { emailMatchers } from "unemail/test" * expect.extend(emailMatchers) * ``` * * Adds: * - `toHaveSent(match)` — any sent email matches the partial. * - `toHaveSentTo(address)` — any sent email contains this recipient. * - `toHaveSentWithSubject(pattern)` — subject matches exact or regex. * - `toHaveSentWithAttachment(filename | predicate)`. * - `toHaveSentMatching(predicate)` — fully custom. */ export type MatcherResult = { pass: boolean; message: () => string; }; export type AttachmentPredicate = (a: NonNullable[number]) => boolean; type HasInbox = { inbox: readonly EmailMessage[]; }; export declare function toHaveSent(received: HasInbox, match: EmailMatch): MatcherResult; export declare function toHaveSentTo(received: HasInbox, recipient: string): MatcherResult; export declare function toHaveSentWithSubject(received: HasInbox, pattern: string | RegExp): MatcherResult; export declare function toHaveSentWithAttachment(received: HasInbox, match: string | AttachmentPredicate): MatcherResult; export declare function toHaveSentMatching(received: HasInbox, predicate: (msg: EmailMessage) => boolean): MatcherResult; /** Vitest-compatible matcher object. Has an explicit index signature * so it type-checks against `expect.extend`'s `MatchersObject`. */ export declare const emailMatchers: { toHaveSent: typeof toHaveSent; toHaveSentTo: typeof toHaveSentTo; toHaveSentWithSubject: typeof toHaveSentWithSubject; toHaveSentWithAttachment: typeof toHaveSentWithAttachment; toHaveSentMatching: typeof toHaveSentMatching; }; /** Snapshot helper — returns a stable, serializable view of an email. * Volatile fields (Message-ID, Date, random boundaries) are normalized * so snapshots survive reruns. */ export declare function toEmailSnapshot(msg: EmailMessage): Record; export {};