-
Notifications
You must be signed in to change notification settings - Fork 1
Contact tests #615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
davidabram
wants to merge
18
commits into
main
Choose a base branch
from
feat/contact-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Contact tests #615
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
a519807
init tests
davidabram a1c1fcf
test workflow
davidabram 14cd055
remove unused packages
davidabram 3dcd2a3
bun i
davidabram c144e3b
fix workflow
davidabram 604881b
turbo env vars
davidabram 2558e21
add comment
davidabram 806a0bb
Updated tests changes to contact/route
Ante-Koceic 65476c8
Testing
Ante-Koceic 626e54e
Testing 2
Ante-Koceic e741fe3
Added logs
Ante-Koceic 06f5fa8
Removed logs
Ante-Koceic 58a3087
Added tests for headers in response, fixed notion create page mock
Ante-Koceic abaa1f1
Added sending message on slack if Notion page was not created
Ante-Koceic 2f909f9
Added test for email helper
Ante-Koceic a9d2933
Minor adjustments
Ante-Koceic 6e1f259
Added missing try-catch
Ante-Koceic 3c7e63c
Fixed incorect import
Ante-Koceic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,35 @@ | ||
| name: Test | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| pull_request: | ||
| branches: ["main"] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Run Tests | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Harden Runner | ||
| uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 | ||
| with: | ||
| egress-policy: audit | ||
|
|
||
| - name: Checkout repository | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
|
|
||
| - name: Setup Bun | ||
| uses: oven-sh/setup-bun@4bc047ad259df6fc24a6c9b0f9a0cb08cf17fbe5 # v1 | ||
| with: | ||
| bun-version: "1.2.21" | ||
|
|
||
| - name: Install dependencies | ||
| run: bun install | ||
|
|
||
| - name: Run tests | ||
| run: bun run test |
This file contains hidden or 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 hidden or 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 hidden or 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,2 @@ | ||
| [test] | ||
| # Test configuration |
This file contains hidden or 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,58 @@ | ||
| import { expect, describe, it, mock, beforeEach, afterEach } from "bun:test"; | ||
|
|
||
| const mockSendMail = mock(() => { | ||
| return Promise.resolve({}); | ||
| }); | ||
|
|
||
| mock.module("@aws-sdk/client-sesv2", () => { | ||
| class MockSESv2Client { | ||
| send = mockSendMail; | ||
| } | ||
|
|
||
| class MockSendEmailCommand { | ||
| constructor(args: any) { | ||
| return args; | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| SESv2Client: MockSESv2Client, | ||
| SendEmailCommand: MockSendEmailCommand, | ||
| }; | ||
| }); | ||
|
|
||
| const originalEnv = process.env; | ||
| beforeEach(() => { | ||
| process.env = { | ||
| ...originalEnv, | ||
| AWS_REGION: "us-east-1", | ||
| EMAIL_AWS_ACCESS_KEY: "mock-aws-access-key", | ||
| EMAIL_AWS_SECRET_ACCESS_KEY: "mock-aws-secret-access-key", | ||
| }; | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| process.env = originalEnv; | ||
| mockSendMail.mockReset(); | ||
| }); | ||
|
|
||
| const { sendEmail } = await import("./email"); | ||
|
|
||
| describe("Email Helper", () => { | ||
| const MockEmailTemplate = () => <>Hello</>; | ||
| const options = { | ||
| from: "from@example.com", | ||
| to: "to@example.com", | ||
| subject: "Test", | ||
| }; | ||
| describe("sendEmail", () => { | ||
| it("should send email with correct arguments", async () => { | ||
| await sendEmail({ | ||
| template: <MockEmailTemplate />, | ||
| options: options, | ||
| }); | ||
|
|
||
| expect(mockSendMail).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.