Web.MastodonAPI.MastodonAPIControllerTest: Add tests against bookmark endpoints

This commit is contained in:
Haelwenn (lanodan) Monnier 2018-12-14 15:20:10 +01:00
parent 27808596ff
commit 5b4eccf9e7
No known key found for this signature in database
GPG Key ID: D5B7A8E43C997DEE
1 changed files with 26 additions and 0 deletions

View File

@ -1429,4 +1429,30 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
user = User.get_cached_by_ap_id(user.ap_id)
assert user.info.settings == %{"programming" => "socks"}
end
test "bookmarks" do
user = insert(:user)
{:ok, activity} =
CommonAPI.post(user, %{
"status" => "heweoo!"
})
response = build_conn()
|> assign(:user, user)
|> post("/api/v1/statuses/#{activity.id}/bookmark")
bookmarks = build_conn()
|> assign(:user, user)
|> get("/api/v1/bookmarks")
assert [json_response(response, 200)] == json_response(bookmarks, 200)
assert json_response(response, 200)["bookmarked"] == true
response2 = build_conn()
|> assign(:user, user)
|> post("/api/v1/statuses/#{activity.id}/unbookmark")
assert json_response(response2, 200)["bookmarked"] == false
end
end