This commit is contained in:
Leandro Facchinetti 2021-03-13 11:44:21 +00:00
parent 448cc22c6a
commit bf6b6d7d90
1 changed files with 3 additions and 1 deletions

View File

@ -13,6 +13,7 @@ let webServer: http.Server;
let emailServer: net.Server; let emailServer: net.Server;
let webClient: got.Got; let webClient: got.Got;
let emailClient: nodemailer.Transporter; let emailClient: nodemailer.Transporter;
let emailHost: string;
beforeAll(() => { beforeAll(() => {
const rootDirectory = fs.mkdtempSync( const rootDirectory = fs.mkdtempSync(
path.join(os.tmpdir(), "kill-the-newsletter--test--") path.join(os.tmpdir(), "kill-the-newsletter--test--")
@ -24,6 +25,7 @@ beforeAll(() => {
); );
webClient = got.default.extend({ prefixUrl: webApplication.get("url") }); webClient = got.default.extend({ prefixUrl: webApplication.get("url") });
emailClient = nodemailer.createTransport(webApplication.get("email")); emailClient = nodemailer.createTransport(webApplication.get("email"));
emailHost = new URL(webApplication.get("url")).hostname;
}); });
afterAll(() => { afterAll(() => {
webServer.close(); webServer.close();
@ -61,7 +63,7 @@ describe("Receive email", () => {
const feedBefore = (await webClient.get(`feeds/${feedReference}.xml`)).body; const feedBefore = (await webClient.get(`feeds/${feedReference}.xml`)).body;
await emailClient.sendMail({ await emailClient.sendMail({
from: "publisher@example.com", from: "publisher@example.com",
to: `${feedReference}@$localhost`, to: `${feedReference}@${emailHost}`,
subject: "A subject", subject: "A subject",
html: html`<p>Some HTML content</p>`, html: html`<p>Some HTML content</p>`,
}); });