2018-12-14 16:41:55 +00:00
|
|
|
defmodule MobilizonWeb.Resolvers.CommentResolverTest do
|
|
|
|
use MobilizonWeb.ConnCase
|
2019-01-03 10:34:31 +00:00
|
|
|
alias Mobilizon.Actors
|
2018-12-14 16:41:55 +00:00
|
|
|
alias Mobilizon.Actors.{Actor, User}
|
|
|
|
alias MobilizonWeb.AbsintheHelpers
|
|
|
|
|
2019-01-03 10:34:31 +00:00
|
|
|
@comment %{text: "I love this event"}
|
2018-12-14 16:41:55 +00:00
|
|
|
|
|
|
|
setup %{conn: conn} do
|
|
|
|
{:ok, %User{default_actor: %Actor{} = actor} = user} =
|
|
|
|
Actors.register(%{email: "test@test.tld", password: "testest", username: "test"})
|
|
|
|
|
|
|
|
{:ok, conn: conn, actor: actor, user: user}
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "Comment Resolver" do
|
|
|
|
test "create_comment/3 creates a comment", %{conn: conn, actor: actor, user: user} do
|
|
|
|
mutation = """
|
|
|
|
mutation {
|
|
|
|
createComment(
|
2019-01-03 10:34:31 +00:00
|
|
|
text: "#{@comment.text}",
|
2018-12-14 16:41:55 +00:00
|
|
|
actor_username: "#{actor.preferred_username}"
|
|
|
|
) {
|
|
|
|
text,
|
|
|
|
uuid
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> auth_conn(user)
|
|
|
|
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
|
|
|
|
|
2019-01-03 10:34:31 +00:00
|
|
|
assert json_response(res, 200)["data"]["createComment"]["text"] == @comment.text
|
2018-12-14 16:41:55 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|