61 lines
2.2 KiB
Elixir
61 lines
2.2 KiB
Elixir
defmodule NullaWeb.ActorControllerTest do
|
|
use NullaWeb.ConnCase
|
|
import Nulla.Fixtures.Data
|
|
|
|
setup do
|
|
create_data()
|
|
:ok
|
|
end
|
|
|
|
describe "GET /users/username" do
|
|
test "renders ActivityPub JSON if Accept header is activity+json", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> put_req_header("accept", "application/activity+json")
|
|
|> get(~p"/users/test")
|
|
|
|
assert response = json_response(conn, 200)
|
|
|
|
assert is_list(response["@context"])
|
|
assert is_binary(response["id"])
|
|
assert is_binary(response["type"])
|
|
assert is_binary(response["following"])
|
|
assert is_binary(response["followers"])
|
|
assert is_binary(response["inbox"])
|
|
assert is_binary(response["outbox"])
|
|
assert is_binary(response["featured"])
|
|
assert is_binary(response["featuredTags"])
|
|
assert is_binary(response["preferredUsername"])
|
|
assert is_binary(response["name"]) or is_nil(response["name"])
|
|
assert is_binary(response["summary"]) or is_nil(response["summary"])
|
|
assert is_binary(response["url"])
|
|
assert is_boolean(response["manuallyApprovesFollowers"])
|
|
assert is_boolean(response["discoverable"])
|
|
assert is_boolean(response["indexable"])
|
|
assert {:ok, _dt, _offset} = DateTime.from_iso8601(response["published"])
|
|
assert is_boolean(response["memorial"])
|
|
assert is_map(response["publicKey"])
|
|
assert is_list(response["tag"])
|
|
assert is_list(response["attachment"])
|
|
assert is_map(response["endpoints"])
|
|
assert is_map(response["icon"]) or is_nil(response["icon"])
|
|
assert is_map(response["image"]) or is_nil(response["image"])
|
|
assert is_binary(response["vcard:bday"]) or is_nil(response["vcard:bday"])
|
|
assert is_binary(response["vcard:Address"]) or is_nil(response["vcard:Address"])
|
|
end
|
|
|
|
test "renders HTML if Accept header is regular", %{conn: conn} do
|
|
conn = get(conn, ~p"/@test")
|
|
|
|
assert html_response(conn, 200) =~ "test"
|
|
assert html_response(conn, 200) =~ "Test"
|
|
assert html_response(conn, 200) =~ "test@localhost"
|
|
end
|
|
|
|
test "returns 404 if actor not found", %{conn: conn} do
|
|
conn = get(conn, ~p"/@nonexistent")
|
|
|
|
assert json_response(conn, 404)["error"] == "Not Found"
|
|
end
|
|
end
|
|
end
|