Skip to content

Instantly share code, notes, and snippets.

@andrelip
Created July 5, 2017 20:07
Show Gist options
  • Select an option

  • Save andrelip/74e6d4557589a9b07b7777d05f64ee0e to your computer and use it in GitHub Desktop.

Select an option

Save andrelip/74e6d4557589a9b07b7777d05f64ee0e to your computer and use it in GitHub Desktop.
defmodule Arvore.Graphql.Reader.AccountMutationQueryTest do
use Arvore.Web.ConnCase
alias Arvore.Repo
alias Arvore.Accounts.User
alias Arvore.GraphQL.UserSchema
test "should log with their credentials and receive a jwt back", info do
%User{ email: "[email protected]", username: "test",
encrypted_password: "$2a$10$LVa1Lc0P343lFuby.e.F2eAkRjlMUPB3xVQdggXcfg5Smb0jvxTJq" } # 12345678
|> Repo.insert
{:ok, result} = login_mutation
|> Absinthe.run(UserSchema,
variables: %{"login" => "[email protected]",
"password" => "12345678"})
assert get_in(result, [:data, "login", "token"]) != nil
end
def login_mutation do
"""
mutation UserLogin($login: String, $password: String) {
login(login: $login, password: $password) {
token
}
}
"""
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment