diff --git a/src/index.test.ts b/src/index.test.ts index e19b777..3de09e1 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -47,7 +47,7 @@ test("Kill the Newsletter!", async () => { const feedReference = create.match(/\/feeds\/([a-z0-9]{16})\.xml/)![1]; // Test feed properties - let feedOriginal = await webClient.get(`feeds/${feedReference}.xml`); + const feedOriginal = await webClient.get(`feeds/${feedReference}.xml`); expect(feedOriginal.headers["content-type"]).toMatch("application/atom+xml"); expect(feedOriginal.headers["x-robots-tag"]).toBe("noindex"); expect(feedOriginal.body).toMatch(html`A newsletter`); @@ -71,7 +71,7 @@ test("Kill the Newsletter!", async () => { subject: "Test email with HTML", html: html`

Some HTML

`, }); - let feed = (await webClient.get(`feeds/${feedReference}.xml`)).body; + const feed = (await webClient.get(`feeds/${feedReference}.xml`)).body; expect(feed.match(/(.+?)<\/updated>/)![1]).not.toBe( feedOriginal.body.match(/(.+?)<\/updated>/)![1] ); @@ -84,31 +84,30 @@ test("Kill the Newsletter!", async () => { html`${`

Some HTML

`}\n
` ); - // Test email with plain text + // Test email with text await emailClient.sendMail({ from: "publisher@example.com", to: `${feedReference}@${emailHost}`, - subject: "Test email with plain text", - text: "Some plain text", - }); - feed = (await webClient.get(`feeds/${feedReference}.xml`)).body; - expect(feed).toMatch( - html`${`

Some plain text

`}
` - ); - - // Test email with rich text - await emailClient.sendMail({ - from: "publisher@example.com", - to: `${feedReference}@${emailHost}`, - subject: "Test email with rich text", + subject: "Test email with text", text: "A link: https://kill-the-newsletter.com", }); - feed = (await webClient.get(`feeds/${feedReference}.xml`)).body; - expect(feed).toMatch( + expect((await webClient.get(`feeds/${feedReference}.xml`)).body).toMatch( // prettier-ignore html`${`

A link: https://kill-the-newsletter.com

`}
` ); + // Test emails with missing fields + // await emailClient.sendMail({ + // from: "publisher@example.com", + // to: `${feedReference}@${emailHost}`, + // subject: "Test email with text", + // text: "A link: https://kill-the-newsletter.com", + // }); + // expect((await webClient.get(`feeds/${feedReference}.xml`)).body).toMatch( + // // prettier-ignore + // html`${`

A link: https://kill-the-newsletter.com

`}
` + // ); + // Stop servers webServer.close(); emailServer.close(); @@ -116,37 +115,6 @@ test("Kill the Newsletter!", async () => { /* describe("receive email", () => { - test("invalid XML character in HTML", async () => { - const identifier = await createFeed(); - await emailClient.sendMail({ - from: "publisher@example.com", - to: `${identifier}@${EMAIL_DOMAIN}`, - subject: "New Message", - html: "

Invalid XML character (backspace): |\b|πŸ’©

", - }); - const feed = await getFeed(identifier); - const entry = feed.querySelector("feed > entry:first-of-type")!; - expect(entry.querySelector("content")!.textContent).toMatchInlineSnapshot(` - "

Invalid XML character (backspace): ||πŸ’©

- " - `); - }); - - test("invalid XML character in text", async () => { - const identifier = await createFeed(); - await emailClient.sendMail({ - from: "publisher@example.com", - to: `${identifier}@${EMAIL_DOMAIN}`, - subject: "New Message", - text: "Invalid XML character (backspace): |\b|πŸ’©", - }); - const feed = await getFeed(identifier); - const entry = feed.querySelector("feed > entry:first-of-type")!; - expect(entry.querySelector("content")!.textContent).toMatchInlineSnapshot( - `"

Invalid XML character (backspace): ||💩

"` - ); - }); - test("missing β€˜from’", async () => { const identifier = await createFeed(); await emailClient.sendMail({