Skip to content

Commit

Permalink
fix(account): optional data server
Browse files Browse the repository at this point in the history
  • Loading branch information
darienmh committed Mar 10, 2024
1 parent 6df3c7b commit 965c437
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 44 deletions.
18 changes: 10 additions & 8 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -24,15 +24,17 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
Expand Down
19 changes: 9 additions & 10 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@ on:

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
2 changes: 1 addition & 1 deletion package-lock.json

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

44 changes: 20 additions & 24 deletions src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,34 +72,30 @@ export class Account {
* @param params.password The password for authenticating with both SMTP and IMAP servers.
*/
constructor(params: AccountParams) {
this.smtpHost = params.smtpHost ?? '';
this.smtpPort = params.smtpPort ?? 0;
this.smtpSecure = params.smtpSecure ?? false;
this.imapHost = params.imapHost ?? '';
this.imapPort = params.imapPort ?? 0;
this.imapSecure = params.imapSecure ?? false;
this.smtpHost = params.smtpHost ?? 'smtp.ethereal.email';
this.smtpPort = params.smtpPort ?? 587;
this.smtpSecure = params.smtpSecure ?? true;
this.imapHost = params.imapHost ?? 'imap.ethereal.email';
this.imapPort = params.imapPort ?? 993;
this.imapSecure = params.imapSecure ?? true;
this.username = params.username;
this.password = params.password;

if (params.smtpHost !== '' && params.smtpPort) {
this._createTransport({
host: this.smtpHost,
port: this.smtpPort,
secure: this.smtpSecure,
username: this.username,
password: this.password,
});
}
this._createTransport({
host: this.smtpHost,
port: this.smtpPort,
secure: this.smtpSecure,
username: this.username,
password: this.password,
});

if (params.imapHost !== '' && params.imapPort) {
this._createClient({
host: this.imapHost,
port: this.imapPort,
secure: this.imapSecure,
username: this.username,
password: this.password,
});
}
this._createClient({
host: this.imapHost,
port: this.imapPort,
secure: this.imapSecure,
username: this.username,
password: this.password,
});
}
/**
* Creates a nodemailer Transporter for SMTP operations.
Expand Down
10 changes: 10 additions & 0 deletions test/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ describe('Account', () => {
expect(password).toBeDefined();
});

it('create account with default service', async () => {
const accountParams = {
username: testUser,
password: testPass,
};
const { username, password } = await createAccount(accountParams);
expect(username).toMatch(regexEmail);
expect(password).toBeDefined();
});

it('create random account with ethereal service', async () => {
const { username, password } = await createRandomAccount();
expect(username).toMatch(regexEmail);
Expand Down

0 comments on commit 965c437

Please sign in to comment.