82 lines
2.4 KiB
Elixir
82 lines
2.4 KiB
Elixir
defmodule NullaWeb.FollowControllerTest do
|
|
use NullaWeb.ConnCase
|
|
|
|
setup do
|
|
Nulla.Fixtures.Data.create()
|
|
:ok
|
|
end
|
|
|
|
describe "GET /users/username/following" do
|
|
test "returns ActivityPub JSON of following", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> get(~p"/users/test/following")
|
|
|
|
assert response = json_response(conn, 200)
|
|
|
|
assert response["id"] == "http://localhost/users/test/following"
|
|
assert response["type"] == "OrderedCollection"
|
|
assert response["totalItems"] == 0
|
|
assert response["first"] == "http://localhost/users/test/following?page=1"
|
|
end
|
|
|
|
test "returns ActivityPub JSON of following with page", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> get(~p"/users/test/following?page=1")
|
|
|
|
assert response = json_response(conn, 200)
|
|
|
|
assert response["id"] == "http://localhost/users/test/following?page=1"
|
|
assert response["type"] == "OrderedCollectionPage"
|
|
assert response["totalItems"] == 0
|
|
assert response["partOf"] == "http://localhost/users/test/following"
|
|
assert is_list(response["orderedItems"])
|
|
end
|
|
|
|
test "returns first page with invalid value", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> get(~p"/users/test/following?page=abc")
|
|
|
|
assert conn.status == 200
|
|
end
|
|
end
|
|
|
|
describe "GET /users/username/followers" do
|
|
test "returns ActivityPub JSON of followers", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> get(~p"/users/test/followers")
|
|
|
|
assert response = json_response(conn, 200)
|
|
|
|
assert response["id"] == "http://localhost/users/test/followers"
|
|
assert response["type"] == "OrderedCollection"
|
|
assert response["totalItems"] == 0
|
|
assert response["first"] == "http://localhost/users/test/followers?page=1"
|
|
end
|
|
|
|
test "returns ActivityPub JSON of followers with page", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> get(~p"/users/test/followers?page=1")
|
|
|
|
assert response = json_response(conn, 200)
|
|
|
|
assert response["id"] == "http://localhost/users/test/followers?page=1"
|
|
assert response["type"] == "OrderedCollectionPage"
|
|
assert response["totalItems"] == 0
|
|
assert response["partOf"] == "http://localhost/users/test/followers"
|
|
assert is_list(response["orderedItems"])
|
|
end
|
|
|
|
test "returns first page with invalid value", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> get(~p"/users/test/followers?page=abc")
|
|
|
|
assert conn.status == 200
|
|
end
|
|
end
|
|
end
|