diff --git a/backend/src/schema/resolvers/notifications.spec.js b/backend/src/schema/resolvers/notifications.spec.js index 280544852..83d308428 100644 --- a/backend/src/schema/resolvers/notifications.spec.js +++ b/backend/src/schema/resolvers/notifications.spec.js @@ -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: [] } }) }) }) }) diff --git a/backend/src/seed/factories/comments.js b/backend/src/seed/factories/comments.js index 33d9464ae..de3390e1a 100644 --- a/backend/src/seed/factories/comments.js +++ b/backend/src/seed/factories/comments.js @@ -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'))