Skip to content

Commit

Permalink
Make generated email address accessible
Browse files Browse the repository at this point in the history
  • Loading branch information
rconner46 committed Jan 3, 2024
1 parent 67f5a7b commit 46776df
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/email/inbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ParsedMail, simpleParser } from 'mailparser';

export class Inbox {
constructor(
private emailAddress: string,
public readonly emailAddress: string,
private autoApi: AutoApi
) {}

Expand Down
7 changes: 5 additions & 2 deletions test/email.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import { EmailAddressResponse } from "../src/dto.ts";

import { EmailHelper } from "../src/email-helper.ts";
import { AddressObject } from "mailparser";
import { randomUUID } from "crypto";

jest.mock('../src/auto-api.ts', () => {
return {
AutoApi: jest.fn().mockImplementation(() => {
return {
getEmailAddress: function(addr: string): Promise<{data: EmailAddressResponse }> {
return Promise.resolve({
data: { emailAddress: addr },
data: { emailAddress: addr + "@example.com" },
status: 200,
statusText: 'Ok',
});
Expand All @@ -36,7 +37,9 @@ describe('email tests', () => {
apiKey: 'apiKey',
productId: -1,
}));
var inbox = await emailHelper.getInbox("email-address-prefix");
const uuid = randomUUID()
var inbox = await emailHelper.getInbox(uuid);
expect(inbox.emailAddress).toBe(uuid + "@example.com");
var email = await inbox.getEmail();
expect(email.from?.text).toBe("[email protected]");
expect((<AddressObject> email.to)?.text).toBe("[email protected]");
Expand Down

0 comments on commit 46776df

Please sign in to comment.