Changeset View
Changeset View
Standalone View
Standalone View
lib/app/base-chips/collections/password-reset-intents.subtest.js
const locreq = require("locreq")(__dirname); | const locreq = require("locreq")(__dirname); | ||||
const axios = require("axios"); | const axios = require("axios"); | ||||
const assert = require("assert"); | const assert = require("assert"); | ||||
const { promise_timeout } = locreq("test_utils"); | |||||
const { with_running_app, with_running_app_prod } = locreq( | const { with_running_app, with_running_app_prod } = locreq( | ||||
"test_utils/with-test-app.js" | "test_utils/with-test-app.js" | ||||
); | ); | ||||
describe("password-reset-intents", () => { | describe("password-reset-intents", () => { | ||||
async function create_a_user(app) { | async function create_a_user(app) { | ||||
await app.run_action( | await app.run_action( | ||||
new app.Sealious.SuperContext(), | new app.Sealious.SuperContext(), | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | with_running_app(async ({ base_url }) => { | ||||
return; | return; | ||||
} | } | ||||
throw new Error("it didn't throw"); | throw new Error("it didn't throw"); | ||||
})); | })); | ||||
it("sends an email with the reset password link", async () => | it("sends an email with the reset password link", async () => | ||||
with_running_app_prod(async ({ app, base_url, mail_api }) => { | with_running_app_prod(async ({ app, base_url, mail_api }) => { | ||||
await create_a_user(app); | await create_a_user(app); | ||||
const data = (await axios.post( | await axios.post( | ||||
`${base_url}/api/v1/collections/password-reset-intents`, | `${base_url}/api/v1/collections/password-reset-intents`, | ||||
{ | { | ||||
email: "user@example.com", | email: "user@example.com", | ||||
} | } | ||||
)).data; | ); | ||||
const messages = (await mail_api.get_messages()).filter( | const messages = (await mail_api.get_messages()).filter( | ||||
message => message.recipients[0] == "<user@example.com>" | message => message.recipients[0] === "<user@example.com>" | ||||
); | ); | ||||
assert(messages.length, 1); | assert(messages.length, 1); | ||||
assert.equal(messages[0].recipients.length, 1); | assert.equal(messages[0].recipients.length, 1); | ||||
assert.equal(messages[0].recipients[0], "<user@example.com>"); | assert.equal(messages[0].recipients[0], "<user@example.com>"); | ||||
})); | })); | ||||
}); | }); |