Move GQL mutation 'loginMutation' in 'user_management.spec.js' into a separate file

This commit is contained in:
Wolfgang Huß 2022-08-15 15:01:26 +02:00
parent 916dfbb46e
commit 0f8abe770a
2 changed files with 14 additions and 6 deletions

View File

@ -0,0 +1,13 @@
import gql from 'graphql-tag'
// ------ mutations
export const loginMutation = gql`
mutation ($email: String!, $password: String!) {
login(email: $email, password: $password)
}
`
// ------ queries
// fill queries in here

View File

@ -2,6 +2,7 @@ import jwt from 'jsonwebtoken'
import CONFIG from './../../config'
import Factory, { cleanDatabase } from '../../db/factories'
import { gql } from '../../helpers/jest'
import { loginMutation } from '../../db/graphql/userManagement'
import { createTestClient } from 'apollo-server-testing'
import createServer, { context } from '../../server'
import encode from '../../jwt/encode'
@ -177,12 +178,6 @@ describe('currentUser', () => {
})
describe('login', () => {
const loginMutation = gql`
mutation ($email: String!, $password: String!) {
login(email: $email, password: $password)
}
`
const respondsWith = async (expected) => {
await expect(mutate({ mutation: loginMutation, variables })).resolves.toMatchObject(expected)
}