From 08adff74bf8d63c4792bdf704d85d0baeaf36025 Mon Sep 17 00:00:00 2001 From: aonomike Date: Sat, 19 Oct 2019 15:08:26 +0300 Subject: [PATCH] Refactor tests for reporting a tag --- backend/src/schema/resolvers/reports.spec.js | 61 +++++++++----------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/backend/src/schema/resolvers/reports.spec.js b/backend/src/schema/resolvers/reports.spec.js index a2b4fc081..1e3c4e371 100644 --- a/backend/src/schema/resolvers/reports.spec.js +++ b/backend/src/schema/resolvers/reports.spec.js @@ -8,7 +8,7 @@ const factory = Factory() const instance = getNeode() const driver = getDriver() -describe('report', () => { +describe('report resources', () => { let authenticatedUser, currentUser, mutate, query const reportMutation = gql` mutation($resourceId: ID!, $reasonCategory: ReasonCategory!, $reasonDescription: String!) { @@ -387,42 +387,37 @@ describe('report', () => { }) }) }) - /* An der Stelle würde ich den c34 noch mal prüfen, diesmal muss aber eine error meldung kommen. - At this point I would check the c34 again, but this time there must be an error message. */ + /* An der Stelle würde ich den comment-to-report-id noch mal prüfen, diesmal muss aber eine error meldung kommen. + At this point I would check the comment-to-report-id again, but this time there must be an error message. */ + describe('reported resource is a tag', () => { + beforeEach(async () => { + await factory.create('Tag', { + id: 'tag-to-report-id', + }) + }) + + it('returns null', async () => { + await expect( + mutate({ + mutation: reportMutation, + variables: { + ...variables, + resourceId: 'tag-to-report-id', + }, + }), + ).resolves.toMatchObject({ + data: { report: null }, + errors: undefined, + }) + }) + }) + + /* An der Stelle würde ich den tag-to-report-id noch mal prüfen, diesmal muss aber eine error meldung kommen. +// At this point I would check the tag-to-report-id again, but this time there must be an error message. */ }) }) }) }) -// describe('report mutation', () => { -// describe('authenticated', () => { - -// describe('valid resource id', () => { - -// describe('reported resource is a post', () => { - -// describe('reported resource is a tag', () => { -// beforeEach(async () => { -// await factory.create('Tag', { -// id: 't23', -// }) -// variables = { -// ...variables, -// resourceId: 't23', -// } -// }) - -// it('returns null', async () => { -// await expect(action()).resolves.toMatchObject({ -// report: null, -// }) -// }) -// }) - -// /* An der Stelle würde ich den t23 noch mal prüfen, diesmal muss aber eine error meldung kommen. -// At this point I would check the t23 again, but this time there must be an error message. */ -// }) -// }) -// }) // describe('reports query', () => { // let query, mutate, authenticatedUser, moderator, user, author