-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor to send welcome email to the user * implement send email with mailgun * implement send email with mailgun * add huskey * update ci * update ci * update ci
- Loading branch information
1 parent
c768d49
commit 2368534
Showing
15 changed files
with
237 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
npm run lint:check | ||
npm run format:check | ||
npm run test:unit -- --run |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ describe("RegisterUser", () => { | |
vi.spyOn(userRepository, "save") | ||
idGenerator = new IdGeneratorMock() | ||
emailSender = new EmailSenderMock() | ||
vi.spyOn(emailSender, "send") | ||
vi.spyOn(emailSender, "sendWelcomeEmail") | ||
registerUser = new RegisterUser(userRepository, idGenerator, emailSender) | ||
}) | ||
|
||
|
@@ -51,10 +51,14 @@ describe("RegisterUser", () => { | |
}) | ||
|
||
it("sends a welcome email to the user", async () => { | ||
const name = "John Doe" | ||
const email = "[email protected]" | ||
const age = 18 | ||
const password = "password" | ||
|
||
await registerUser.execute(notImportantName, email, notImportantPassword, notImportantAge) | ||
|
||
expect(emailSender.send).toHaveBeenCalledWith(email, "Welcome to our platform!") | ||
const user = User.create(IdGeneratorMock.MOCK_ID, name, email, password, age) | ||
expect(emailSender.sendWelcomeEmail).toHaveBeenCalledWith(user) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export class EmailSender { | ||
// eslint-disable-next-line no-unused-vars | ||
send(email, message) { | ||
sendWelcomeEmail(user) { | ||
throw new Error("This is an abstract class. You should implement the send method") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export const config = { | ||
mailgun: { | ||
apiKey: process.env.MAILGUN_API_KEY ?? "", | ||
domain: process.env.MAILGUN_DOMAIN ?? "sandbox261f754ab73b43388177e85a621a13fb.mailgun.org", | ||
fromAddressStart: "mailgun", // this means mailgun@domain.com | ||
fromAddressName: "Dan", | ||
}, | ||
testmail: { | ||
apiKey: process.env.TESTMAIL_API_KEY ?? "", | ||
namespace: process.env.TESTMAIL_NAMESPACE ?? "9eqfr", | ||
}, | ||
} |
Oops, something went wrong.