Fix users and report resolver specs

This time I did not refactor the whole tests suites because of time and
complexity of the PR review.
This commit is contained in:
roschaefer 2019-08-31 00:47:40 +02:00
parent 36ba4cc208
commit 3f5ac61b73
2 changed files with 14 additions and 18 deletions

View File

@ -12,6 +12,7 @@ describe('report', () => {
let returnedObject
let variables
let createPostVariables
let user
const categoryIds = ['cat9']
beforeEach(async () => {
@ -20,10 +21,10 @@ describe('report', () => {
id: 'whatever',
}
headers = {}
await factory.create('User', {
id: 'u1',
user = await factory.create('User', {
email: 'test@example.org',
password: '1234',
id: 'u1',
})
await factory.create('User', {
id: 'u2',
@ -127,11 +128,8 @@ describe('report', () => {
describe('reported resource is a post', () => {
beforeEach(async () => {
await factory.authenticateAs({
email: 'test@example.org',
password: '1234',
})
await factory.create('Post', {
author: user,
id: 'p23',
title: 'Matt and Robert having a pair-programming',
categoryIds,
@ -182,12 +180,9 @@ describe('report', () => {
content: 'please comment on me',
categoryIds,
}
const asAuthenticatedUser = await factory.authenticateAs({
email: 'test@example.org',
password: '1234',
})
await asAuthenticatedUser.create('Post', createPostVariables)
await asAuthenticatedUser.create('Comment', {
await factory.create('Post', { ...createPostVariables, author: user })
await factory.create('Comment', {
author: user,
postId: 'p1',
id: 'c34',
content: 'Robert getting tired.',

View File

@ -7,6 +7,7 @@ let client
const factory = Factory()
const instance = neode()
const categoryIds = ['cat9']
let user
afterEach(async () => {
await factory.cleanDatabase()
@ -132,7 +133,6 @@ describe('users', () => {
describe('DeleteUser', () => {
let deleteUserVariables
let asAuthor
const deleteUserMutation = gql`
mutation($id: ID!, $resource: [Deletable]) {
DeleteUser(id: $id, resource: $resource) {
@ -149,7 +149,7 @@ describe('users', () => {
}
`
beforeEach(async () => {
await factory.create('User', {
user = await factory.create('User', {
email: 'test@example.org',
password: '1234',
id: 'u343',
@ -193,8 +193,7 @@ describe('users', () => {
describe('attempting to delete my own account', () => {
let expectedResponse
beforeEach(async () => {
asAuthor = Factory()
await asAuthor.authenticateAs({
await factory.authenticateAs({
email: 'test@example.org',
password: '1234',
})
@ -203,12 +202,14 @@ describe('users', () => {
name: 'Democracy & Politics',
icon: 'university',
})
await asAuthor.create('Post', {
await factory.create('Post', {
author: user,
id: 'p139',
content: 'Post by user u343',
categoryIds,
})
await asAuthor.create('Comment', {
await factory.create('Comment', {
author: user,
id: 'c155',
postId: 'p139',
content: 'Comment by user u343',