write first test and let changeset errors return error json in controller

This commit is contained in:
2021-12-02 22:45:39 -05:00
parent 89c2a99283
commit d32dc8c2cb
7 changed files with 148 additions and 13 deletions

View File

@@ -0,0 +1,27 @@
defmodule EntenduWeb.ErrorViewTest do
use EntenduWeb.ConnCase, async: true
# Bring render/3 and render_to_string/3 for testing custom views
import Phoenix.View
test "renders 404.html" do
assert render_to_string(EntenduWeb.ErrorView, "404.html", []) == "Not Found"
end
test "just endpoint creates a link with valid attrs", %{conn: conn} do
params = %{
"text_content" => "some gibberish",
"filename" => "more gibberish"
}
conn = post(conn, Routes.link_path(conn, :just), params)
response = json_response(conn, 201)
assert %{
"id" => _link_id,
"text_content" => "some gibberish",
"filename" => "more gibberish"
} = response
end
end