Skip to content

Commit

Permalink
unsorted tests (#26)
Browse files Browse the repository at this point in the history
for mailgun adapter body params
  • Loading branch information
ah-s76 authored Sep 20, 2023
1 parent 2d44f62 commit 9f085e3
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions test/bullhorn/mailgun_param_adapter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ defmodule Bullhorn.MailgunParamAdapterTest do
)
|> MailgunParamAdapter.mailgun_body()

assert request_body == "to=destination%40example.com&from=source%40example.com&subject=test+subject"
assert String.contains?(request_body, "to=destination%40example.com")
assert String.contains?(request_body, "from=source%40example.com")
assert String.contains?(request_body, "subject=test+subject")
end

test "builds with attachments" do
Expand All @@ -32,14 +34,15 @@ defmodule Bullhorn.MailgunParamAdapterTest do
|> put_attachment(%Bamboo.Attachment{filename: "test file", data: "data"})
|> MailgunParamAdapter.mailgun_body()

assert request_body ==
{:multipart,
[
{"to", "[email protected]"},
{"from", "[email protected]"},
{"subject", "test subject"},
{"", "data", {"form-data", [{"name", "\"attachment\""}, {"filename", "\"test file\""}]}, []}
]}
{:multipart, body_params} = request_body
assert Enum.member?(body_params, {"to", "[email protected]"})
assert Enum.member?(body_params, {"from", "[email protected]"})
assert Enum.member?(body_params, {"subject", "test subject"})

assert Enum.member?(
body_params,
{"", "data", {"form-data", [{"name", "\"attachment\""}, {"filename", "\"test file\""}]}, []}
)
end

test "builds with headers" do
Expand All @@ -53,8 +56,10 @@ defmodule Bullhorn.MailgunParamAdapterTest do
|> MailgunHelper.substitute_variables("first_name", "Name")
|> MailgunParamAdapter.mailgun_body()

assert request_body ==
"to=destination%40example.com&from=source%40example.com&subject=email+with+header+vars&h%3AX-Mailgun-Variables=%7B%22first_name%22%3A%22Name%22%7D"
assert String.contains?(request_body, "to=destination%40example.com")
assert String.contains?(request_body, "from=source%40example.com")
assert String.contains?(request_body, "subject=email+with+header+vars")
assert String.contains?(request_body, "h%3AX-Mailgun-Variables=%7B%22first_name%22%3A%22Name%22%7D")
end
end
end

0 comments on commit 9f085e3

Please sign in to comment.