UNPKG

e2e-mailbox

Version:

E2E test your email notification system using GuerrillaMail API.

67 lines (66 loc) 2.62 kB
import { EmailResponse, MailboxProvider } from './types'; export default class IntegrationMailbox { private mailboxProviders; private mailbox; /** --- Public Functions --- */ /** * Creates a mailbox session with the designated provider. By default, * DeveloperMail API will be used. * @param mailboxProvider */ constructor(mailboxProvider?: MailboxProvider); /** * Initialize a session and set the client with an email address. * If one email service is not working, the backup will be used * automatically to prevent disruption. * @returns email address */ createEmailAddress(): Promise<string>; /** * Send an email to this mailbox. Only works for the DeveloperMail provider. * @param subject * @param body * @returns A `boolean` representing success or failure. */ sendSelfMail(subject: string, body: string): Promise<boolean>; /** * Get the current list of emails from the email inbox. * @returns Array of emails */ fetchEmailList(): Promise<EmailResponse[]>; /** * Forget the current email address. This will delete the mailbox and any emails * it contains. * @param emailAddress * @returns True on success, false on failure */ forgetEmailAddress(emailAddress: string): Promise<boolean | undefined>; /** * Delete a specific email by ID. * @param emailId * @returns true on success, false on failure */ deleteEmailById(emailId: string): Promise<boolean | undefined>; /** * Get the contents of an email. All HTML in the body of the email is filtered. * Eg, Javascript, applets, iframes, etc is removed. Subject and email excerpt are escaped using HTML Entities. * Only emails owned by the current session id can be fetched. * @param emailId * @returns */ fetchEmailById(emailId: string): Promise<EmailResponse | undefined>; /** * Wait for email to arrive in inbox, and return the fetched email * @param subjectLine - the subject line belonging to the email. * @param maxLimitInSec - the max time to wait for the email to arrive, default is 60 seconds. * @returns EmailResponse | undefined */ waitForEmail(subjectLine: string, maxLimitInSec?: number): Promise<EmailResponse | undefined>; /** * Extract all urls from <a> hrefs from an email body. This will be returned * as an array of strings containing the urls. * @param email * @returns all hrefs from an email body */ extractLinksFromEmail(email: EmailResponse): string[]; }