44 lines
1.6 KiB
Elixir
44 lines
1.6 KiB
Elixir
defmodule Aprsme.Accounts.UserNotifierTest do
|
|
use ExUnit.Case, async: true
|
|
|
|
import Swoosh.TestAssertions
|
|
|
|
alias Aprsme.Accounts.UserNotifier
|
|
|
|
defp user, do: %{email: "test@example.com"}
|
|
|
|
describe "deliver_confirmation_instructions/2" do
|
|
test "sends a confirmation email with the URL embedded in the body" do
|
|
assert {:ok, email} =
|
|
UserNotifier.deliver_confirmation_instructions(user(), "https://aprs.me/confirm/abc")
|
|
|
|
assert email.subject == "Confirmation instructions"
|
|
assert email.to == [{"", "test@example.com"}]
|
|
assert email.text_body =~ "You can confirm your account"
|
|
assert email.text_body =~ "https://aprs.me/confirm/abc"
|
|
assert_email_sent(email)
|
|
end
|
|
end
|
|
|
|
describe "deliver_reset_password_instructions/2" do
|
|
test "sends a password reset email with the URL embedded in the body" do
|
|
assert {:ok, email} =
|
|
UserNotifier.deliver_reset_password_instructions(user(), "https://aprs.me/reset/xyz")
|
|
|
|
assert email.subject == "Reset password instructions"
|
|
assert email.text_body =~ "reset your password"
|
|
assert email.text_body =~ "https://aprs.me/reset/xyz"
|
|
end
|
|
end
|
|
|
|
describe "deliver_update_email_instructions/2" do
|
|
test "sends an update-email email with the URL embedded in the body" do
|
|
assert {:ok, email} =
|
|
UserNotifier.deliver_update_email_instructions(user(), "https://aprs.me/update/123")
|
|
|
|
assert email.subject == "Update email instructions"
|
|
assert email.text_body =~ "change your email"
|
|
assert email.text_body =~ "https://aprs.me/update/123"
|
|
end
|
|
end
|
|
end
|