From 1c20e06da5a9817c15c80ca5a25cfacf8eeb0485 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 11 Dec 2023 18:47:59 +0100 Subject: test(services): add tests for createComment mutation * add Jest test * add a Cypress test in article pages spec --- .../graphql/mutators/create-comment.test.ts | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/services/graphql/mutators/create-comment.test.ts (limited to 'src/services/graphql/mutators/create-comment.test.ts') diff --git a/src/services/graphql/mutators/create-comment.test.ts b/src/services/graphql/mutators/create-comment.test.ts new file mode 100644 index 0000000..b3742f5 --- /dev/null +++ b/src/services/graphql/mutators/create-comment.test.ts @@ -0,0 +1,23 @@ +import { describe, expect, it } from '@jest/globals'; +import { type CreateCommentInput, createComment } from './create-comment'; + +describe('create-comment', () => { + it('successfully create a new comment', async () => { + const email: CreateCommentInput = { + author: 'Bruce_Lowe12', + authorEmail: 'Wiley_Wolf18@example.net', + authorUrl: '', + clientMutationId: 'aliquid', + commentOn: 2, + content: 'Error vel fugit nisi accusantium.', + }; + const result = await createComment(email); + + // eslint-disable-next-line @typescript-eslint/no-magic-numbers + expect.assertions(3); + + expect(result.clientMutationId).toBe(email.clientMutationId); + expect(result.comment?.approved).toBe(true); + expect(result.success).toBe(true); + }); +}); -- cgit v1.2.3