From e109b5f6b140ace085087666f3be4e974feb0741 Mon Sep 17 00:00:00 2001 From: aonomike Date: Wed, 18 Sep 2019 17:51:35 +0300 Subject: [PATCH] Refactor disable post updates disabledBy --- .../src/schema/resolvers/moderation.spec.js | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/backend/src/schema/resolvers/moderation.spec.js b/backend/src/schema/resolvers/moderation.spec.js index 64d39ecd1..208332b79 100644 --- a/backend/src/schema/resolvers/moderation.spec.js +++ b/backend/src/schema/resolvers/moderation.spec.js @@ -179,11 +179,35 @@ describe('disable', () => { id: 'sample-post-id', }) }) - + const postQuery = gql` + query($id: ID) { + Post(id: $id) { + id + disabledBy { + id + } + } + } + ` it('returns disabled resource id', async () => { variables = { id: 'sample-post-id' } - const expected = { data: { disable: 'sample-post-id' } } - await expect(mutate({ mutation, variables })).resolves.toMatchObject(expected) + await expect(mutate({ mutation, variables })).resolves.toMatchObject({ + data: { disable: 'sample-post-id' }, + }) + }) + + it.only('changes .disabledBy', async () => { + variables = { id: 'sample-post-id' } + const before = { data: { Post: [{ id: 'sample-post-id', disabledBy: null }] } } + const expected = { + data: { Post: [{ id: 'sample-post-id', disabledBy: { id: 'moderator-id' } }] }, + } + + await expect(query({ query: postQuery, variables })).resolves.toMatchObject(before) + await expect(mutate({ mutation, variables })).resolves.toMatchObject({ + data: { disable: 'sample-post-id' }, + }) + await expect(query({ query: postQuery, variables })).resolves.toMatchObject(expected) }) }) }) @@ -213,12 +237,6 @@ describe('disable', () => { // } // }) - // it('returns disabled resource id', async () => { - // const expected = { disable: 'p9' } - // await setup() - // await expect(action()).resolves.toEqual(expected) - // }) - // it('changes .disabledBy', async () => { // const before = { Post: [{ id: 'p9', disabledBy: null }] } // const expected = { Post: [{ id: 'p9', disabledBy: { id: 'u7' } }] }