From 448cc22c6a2f5ed092f3d0bc0125fb0ff45a5b25 Mon Sep 17 00:00:00 2001 From: Leandro Facchinetti Date: Sat, 13 Mar 2021 11:23:02 +0000 Subject: [PATCH] --- src/index.test.ts | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/index.test.ts b/src/index.test.ts index 6adec53..6c547c2 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -30,7 +30,7 @@ afterAll(() => { emailServer.close(); }); -test("create feed", async () => { +test("Create feed", async () => { const createResponseBody = ( await webClient.post("", { form: { name: "A newsletter" } }) ).body; @@ -53,6 +53,32 @@ test("create feed", async () => { expect(alternateResponse.body).toMatch(`Enjoy your readings!`); }); +describe("Receive email", () => { + test("HTML content", async () => { + const feedReference = ( + await webClient.post("", { form: { name: "A newsletter" } }) + ).body.match(/\/feeds\/([a-z0-9]{16})\.xml/)![1]; + const feedBefore = (await webClient.get(`feeds/${feedReference}.xml`)).body; + await emailClient.sendMail({ + from: "publisher@example.com", + to: `${feedReference}@$localhost`, + subject: "A subject", + html: html`

Some HTML content

`, + }); + const feed = (await webClient.get(`feeds/${feedReference}.xml`)).body; + expect(feed.match(/(.+?)<\/updated>/)![1]).not.toBe( + feedBefore.match(/(.+?)<\/updated>/)![1] + ); + expect(feed).toMatch( + html`publisher@example.com` + ); + expect(feed).toMatch(html`A subject`); + expect(feed).toMatch( + html`${`

Some HTML content

`}
` + ); + }); +}); + /* describe("receive email", () => { test("‘updated’ field is updated", async () => {