-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add subjects to templates * use jsdom-env, add more tests * import template
- Loading branch information
1 parent
6bae8ec
commit 5635a53
Showing
17 changed files
with
287 additions
and
36 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,21 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
import { TestEnvironment } from "jest-environment-jsdom"; | ||
|
||
class CustomTestEnvironment extends TestEnvironment { | ||
async setup() { | ||
await super.setup(); | ||
// TextEncoder is required by node-html-parser | ||
if (typeof this.global.TextEncoder === "undefined") { | ||
const { TextEncoder } = require("util"); | ||
this.global.TextEncoder = TextEncoder; | ||
} | ||
|
||
// setImmediate is required by nodemailer | ||
if (typeof this.global.setImmediate === "undefined") { | ||
const { setImmediate } = require("timers"); | ||
this.global.setImmediate = setImmediate; | ||
} | ||
} | ||
} | ||
|
||
module.exports = CustomTestEnvironment; |
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
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
42 changes: 42 additions & 0 deletions
42
packages/cli/src/pages/api/previews/__test__/__snapshots__/index.test.tsx.snap
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,42 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`index should return previews 1`] = ` | ||
{ | ||
"previewText": { | ||
"/previews/AccountCreated/accountCreated": "Welcome to BookBook, Amelita!", | ||
"/previews/NewSignIn/newSignIn": "Security Alert: New Sign-In Hello Amelita, We noticed a new sign-in to your BookBook account on a Mac device. If this was you, you don’t nee", | ||
"/previews/Reservation/reservationChanged": "Reservation Changed • Salazar in Silver Lake • Sunday, Aug 22 at 1:30pm • Party of 4, patio You’re all set! Your reservation at Salazar has ", | ||
"/previews/Reservation/reservationConfirmed": "Reservation Confirmed • Salazar in Silver Lake • Saturday, Aug 22 at 1:30pm • Party of 4, patio Thanks for booking your reservation at Salaz", | ||
"/previews/Reservation/reservationWithError": "Reservation Canceled • Salazar in Silver Lake • Sunday, Aug 22 at 1:30pm • Party of 4, patio If this was a mistake or if you changed your mi", | ||
"/previews/ResetPassword/resetPassword": "Hello Amelita, We’ve received your request to change your password. Use the link below to set up a new password for your account. This link ", | ||
}, | ||
"previews": [ | ||
[ | ||
"AccountCreated", | ||
[ | ||
"accountCreated", | ||
], | ||
], | ||
[ | ||
"NewSignIn", | ||
[ | ||
"newSignIn", | ||
], | ||
], | ||
[ | ||
"Reservation", | ||
[ | ||
"reservationWithError", | ||
"reservationConfirmed", | ||
"reservationChanged", | ||
], | ||
], | ||
[ | ||
"ResetPassword", | ||
[ | ||
"resetPassword", | ||
], | ||
], | ||
], | ||
} | ||
`; |
37 changes: 37 additions & 0 deletions
37
packages/cli/src/pages/api/previews/__test__/index.test.tsx
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,37 @@ | ||
import { NextApiRequest, NextApiResponse } from "next"; | ||
import { createMocks } from "node-mocks-http"; | ||
import index from ".."; | ||
|
||
describe("index", () => { | ||
it("should return previews", async () => { | ||
const { req, res } = createMocks({ | ||
method: "GET", | ||
}); | ||
|
||
await index( | ||
req as unknown as NextApiRequest, | ||
res as unknown as NextApiResponse | ||
); | ||
|
||
expect(res.statusCode).toBe(200); | ||
const json = res._getJSONData(); | ||
expect(json).toMatchSnapshot(); | ||
}); | ||
|
||
it("should return template subject if it exists", async () => { | ||
const { req, res } = createMocks({ | ||
method: "GET", | ||
}); | ||
|
||
await index( | ||
req as unknown as NextApiRequest, | ||
res as unknown as NextApiResponse | ||
); | ||
|
||
expect(res.statusCode).toBe(200); | ||
const json = res._getJSONData(); | ||
expect(json["previewText"]["/previews/AccountCreated/accountCreated"]).toBe( | ||
"Welcome to BookBook, Amelita!" | ||
); | ||
}); | ||
}); |
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
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
Oops, something went wrong.
5635a53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
web-emails – ./packages/web
web-emails-git-main-sofn.vercel.app
emails.mailing.run
mailing-web.vercel.app
web-emails-sofn.vercel.app
5635a53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
mailing-dynamic-demo – ./
demo.mailing.run
mailing-dynamic-demo-sofn.vercel.app
mailing-dynamic-demo.vercel.app
mailing-dynamic-demo-git-main-sofn.vercel.app