Follow @mattwr18's suggestions

This commit is contained in:
roschaefer 2019-09-03 14:54:27 +02:00
parent 0b3bbb1f14
commit 7b44a87e3b
2 changed files with 10 additions and 5 deletions

View File

@ -219,7 +219,7 @@ describe('given some notifications', () => {
})
describe('if a resource gets deleted', () => {
beforeEach(async () => {
const deletePostAction = async () => {
authenticatedUser = await author.toJson()
const deletePostMutation = gql`
mutation($id: ID!) {
@ -233,13 +233,18 @@ describe('given some notifications', () => {
mutate({ mutation: deletePostMutation, variables: { id: 'p3' } }),
).resolves.toMatchObject({ data: { DeletePost: { id: 'p3', deleted: true } } })
authenticatedUser = await user.toJson()
})
}
it('reduces notifications list', async () => {
const expected = expect.objectContaining({ data: { notifications: [] } })
await expect(
query({ query: notificationQuery, variables: { ...variables, read: false } }),
).resolves.toEqual(expected)
).resolves.toMatchObject({
data: { notifications: [expect.any(Object), expect.any(Object)] },
})
await deletePostAction()
await expect(
query({ query: notificationQuery, variables: { ...variables, read: false } }),
).resolves.toMatchObject({ data: { notifications: [] } })
})
})
})

View File

@ -17,7 +17,7 @@ export default function create() {
let { post, postId } = args
delete args.post
delete args.postId
if (post && post) throw new Error('You provided both post and postId')
if (post && postId) throw new Error('You provided both post and postId')
if (postId) post = await neodeInstance.find('Post', postId)
post = post || (await factoryInstance.create('Post'))