test update posts for categories again

This commit is contained in:
Moriz Wahl 2023-03-29 17:26:15 +02:00
parent 0f7c2d014c
commit 2c52d08a94
2 changed files with 29 additions and 8 deletions

View File

@ -32,6 +32,9 @@ export const createPostMutation = () => {
author { author {
name name
} }
categories {
id
}
} }
} }
` `

View File

@ -4,6 +4,9 @@ import gql from 'graphql-tag'
import { getNeode, getDriver } from '../../db/neo4j' import { getNeode, getDriver } from '../../db/neo4j'
import createServer from '../../server' import createServer from '../../server'
import { createPostMutation } from '../../graphql/posts' import { createPostMutation } from '../../graphql/posts'
import CONFIG from '../../config'
CONFIG.CATEGORIES_ACTIVE = true
const driver = getDriver() const driver = getDriver()
const neode = getNeode() const neode = getNeode()
@ -345,8 +348,20 @@ describe('CreatePost', () => {
describe('UpdatePost', () => { describe('UpdatePost', () => {
let author, newlyCreatedPost let author, newlyCreatedPost
const updatePostMutation = gql` const updatePostMutation = gql`
mutation ($id: ID!, $title: String!, $content: String!, $image: ImageInput) { mutation (
UpdatePost(id: $id, title: $title, content: $content, image: $image) { $id: ID!
$title: String!
$content: String!
$image: ImageInput
$categoryIds: [ID]
) {
UpdatePost(
id: $id
title: $title
content: $content
image: $image
categoryIds: $categoryIds
) {
id id
title title
content content
@ -356,6 +371,9 @@ describe('UpdatePost', () => {
} }
createdAt createdAt
updatedAt updatedAt
categories {
id
}
} }
} }
` `
@ -439,12 +457,12 @@ describe('UpdatePost', () => {
expect(newlyCreatedPost.updatedAt).not.toEqual(UpdatePost.updatedAt) expect(newlyCreatedPost.updatedAt).not.toEqual(UpdatePost.updatedAt)
}) })
/* describe('no new category ids provided for update', () => { describe('no new category ids provided for update', () => {
it('resolves and keeps current categories', async () => { it('resolves and keeps current categories', async () => {
const expected = { const expected = {
data: { data: {
UpdatePost: { UpdatePost: {
id: 'p9876', id: newlyCreatedPost.id,
categories: expect.arrayContaining([{ id: 'cat9' }, { id: 'cat4' }, { id: 'cat15' }]), categories: expect.arrayContaining([{ id: 'cat9' }, { id: 'cat4' }, { id: 'cat15' }]),
}, },
}, },
@ -454,9 +472,9 @@ describe('UpdatePost', () => {
expected, expected,
) )
}) })
}) */ })
/* describe('given category ids', () => { describe('given category ids', () => {
beforeEach(() => { beforeEach(() => {
variables = { ...variables, categoryIds: ['cat27'] } variables = { ...variables, categoryIds: ['cat27'] }
}) })
@ -465,7 +483,7 @@ describe('UpdatePost', () => {
const expected = { const expected = {
data: { data: {
UpdatePost: { UpdatePost: {
id: 'p9876', id: newlyCreatedPost.id,
categories: expect.arrayContaining([{ id: 'cat27' }]), categories: expect.arrayContaining([{ id: 'cat27' }]),
}, },
}, },
@ -475,7 +493,7 @@ describe('UpdatePost', () => {
expected, expected,
) )
}) })
}) */ })
describe.skip('params.image', () => { describe.skip('params.image', () => {
describe('is object', () => { describe('is object', () => {