2018-12-14 17:41:55 +01:00
|
|
|
defmodule MobilizonWeb.Resolvers.CommentResolverTest do
|
|
|
|
use MobilizonWeb.ConnCase
|
|
|
|
alias MobilizonWeb.AbsintheHelpers
|
2019-01-25 13:59:58 +01:00
|
|
|
import Mobilizon.Factory
|
2018-12-14 17:41:55 +01:00
|
|
|
|
2019-01-03 11:34:31 +01:00
|
|
|
@comment %{text: "I love this event"}
|
2018-12-14 17:41:55 +01:00
|
|
|
|
|
|
|
setup %{conn: conn} do
|
2019-01-25 13:59:58 +01:00
|
|
|
user = insert(:user)
|
|
|
|
actor = insert(:actor, user: user)
|
2018-12-14 17:41:55 +01:00
|
|
|
|
|
|
|
{: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 11:34:31 +01:00
|
|
|
text: "#{@comment.text}",
|
2019-10-25 17:43:37 +02:00
|
|
|
actor_id: "#{actor.id}"
|
2018-12-14 17:41:55 +01:00
|
|
|
) {
|
|
|
|
text,
|
|
|
|
uuid
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> auth_conn(user)
|
|
|
|
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
|
|
|
|
|
2019-01-03 11:34:31 +01:00
|
|
|
assert json_response(res, 200)["data"]["createComment"]["text"] == @comment.text
|
2018-12-14 17:41:55 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|