Add tests

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
Signed-off-by: marcin mikołajczak <me@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-08-13 00:02:38 +02:00 committed by marcin mikołajczak
parent 9ffb4d055a
commit 95f18a7296
2 changed files with 27 additions and 1 deletions

View file

@ -173,4 +173,23 @@ test "accepts a Question with no content" do
assert {:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(data)
end
test "it strips voters list and displays voters count instead" do
user = insert(:user)
other_user = insert(:user)
{:ok, activity} =
CommonAPI.post(user, %{
status: "???",
poll: %{expires_in: 10, options: ["yes", "no"]}
})
object = Object.normalize(activity, fetch: false)
{:ok, _, _} = CommonAPI.vote(other_user, object, [1])
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
refute Map.has_key?(modified["object"], "voters")
assert modified["object"]["votersCount"] == 1
end
end

View file

@ -167,7 +167,14 @@ test "doesn't strips HTML tags" do
} = PollView.render("show.json", %{object: object})
end
test "that poll is non anonymous" do
test "displays correct voters count" do
object = Object.normalize("https://friends.grishka.me/posts/54642", fetch: true)
result = PollView.render("show.json", %{object: object})
assert result[:voters_count] == 14
end
test "detects that poll is non anonymous" do
object = Object.normalize("https://friends.grishka.me/posts/54642", fetch: true)
result = PollView.render("show.json", %{object: object})