From 202316e0a37156e1b0afee92441a95d098d81a57 Mon Sep 17 00:00:00 2001 From: Kapil Jain Date: Thu, 17 Oct 2019 19:45:39 -0400 Subject: [PATCH] Fixed formatting --- backend/src/schema/resolvers/follow.spec.js | 107 ++++++++++---------- backend/src/schema/resolvers/shout.spec.js | 18 ++-- 2 files changed, 63 insertions(+), 62 deletions(-) diff --git a/backend/src/schema/resolvers/follow.spec.js b/backend/src/schema/resolvers/follow.spec.js index 56336a2c6..860b40687 100644 --- a/backend/src/schema/resolvers/follow.spec.js +++ b/backend/src/schema/resolvers/follow.spec.js @@ -106,7 +106,7 @@ describe('follow', () => { mutate({ mutation: mutationFollowUser, variables, - }), + }) ).resolves.toMatchObject({ errors: [{ message: 'Not Authorised!' }], data: { followUser: null }, @@ -124,71 +124,72 @@ describe('follow', () => { mutate({ mutation: mutationFollowUser, variables, - }), + }) ).resolves.toMatchObject({ - data: {followUser: expectedUser}, + data: { followUser: expectedUser }, errors: undefined, }) // Test to make sure FOLLOWS relationship has "createdAt" date. - let relation = await neode.cypher( - 'MATCH (user:User {id: {id}})-[relationship:FOLLOWS]->(followed:User) WHERE relationship.createdAt IS NOT NULL RETURN relationship', - { id: 'u1' }, + const relation = await neode.cypher( + 'MATCH (user:User {id: {id}})-[relationship:FOLLOWS]->(followed:User) WHERE relationship.createdAt IS NOT NULL RETURN relationship', + { id: 'u1' } + ) + const relationshipProperties = relation.records.map( + record => record.get('relationship').properties.createdAt ) - const relationshipProperties = relation.records.map(record => record.get('relationship').properties.createdAt) expect(relationshipProperties[0]).toEqual(expect.any(String)) }) + test('I can`t follow myself', async () => { + variables.id = user1.id + await expect(mutate({ mutation: mutationFollowUser, variables })).resolves.toMatchObject({ + data: { followUser: null }, + errors: undefined, + }) -test('I can`t follow myself', async () => { - variables.id = user1.id - await expect(mutate({ mutation: mutationFollowUser, variables })).resolves.toMatchObject({ - data: { followUser: null }, - errors: undefined, - }) - - const expectedUser = { - followedBy: [], - followedByCurrentUser: false, - } - await expect( - query({ - query: userQuery, - variables: { id: user1.id }, - }), - ).resolves.toMatchObject({ - data: { - User: [expectedUser], - }, - errors: undefined, - }) -}) -}) -describe('unfollow user', () => { - beforeEach(async () => { - variables = { id: user2.id } - await mutate({ mutation: mutationFollowUser, variables }) - }) - - describe('unauthenticated follow', () => { - test('throws authorization error', async () => { - authenticatedUser = null - await expect(mutate({ mutation: mutationUnfollowUser, variables })).resolves.toMatchObject({ - data: { unfollowUser: null }, - errors: [{ message: 'Not Authorised!' }], + const expectedUser = { + followedBy: [], + followedByCurrentUser: false, + } + await expect( + query({ + query: userQuery, + variables: { id: user1.id }, + }) + ).resolves.toMatchObject({ + data: { + User: [expectedUser], + }, + errors: undefined, }) }) }) + describe('unfollow user', () => { + beforeEach(async () => { + variables = { id: user2.id } + await mutate({ mutation: mutationFollowUser, variables }) + }) - test('I can unfollow a user', async () => { - const expectedUser = { - name: user2.name, - followedBy: [], - followedByCurrentUser: false, - } - await expect(mutate({ mutation: mutationUnfollowUser, variables })).resolves.toMatchObject({ - data: { unfollowUser: expectedUser }, - errors: undefined, + describe('unauthenticated follow', () => { + test('throws authorization error', async () => { + authenticatedUser = null + await expect(mutate({ mutation: mutationUnfollowUser, variables })).resolves.toMatchObject({ + data: { unfollowUser: null }, + errors: [{ message: 'Not Authorised!' }], + }) + }) + }) + + test('I can unfollow a user', async () => { + const expectedUser = { + name: user2.name, + followedBy: [], + followedByCurrentUser: false, + } + await expect(mutate({ mutation: mutationUnfollowUser, variables })).resolves.toMatchObject({ + data: { unfollowUser: expectedUser }, + errors: undefined, + }) }) }) }) -}) diff --git a/backend/src/schema/resolvers/shout.spec.js b/backend/src/schema/resolvers/shout.spec.js index ee153404c..400701b05 100644 --- a/backend/src/schema/resolvers/shout.spec.js +++ b/backend/src/schema/resolvers/shout.spec.js @@ -30,10 +30,6 @@ const queryPost = gql` } ` - - - - describe('shout and unshout posts', () => { let currentUser, postAuthor beforeAll(() => { @@ -105,13 +101,17 @@ describe('shout and unshout posts', () => { errors: undefined, }) // Test to make sure SHOUT relationship has "createdAt" date. - let relation = await instance.cypher( - 'MATCH (user:User {id: $userId1})-[relationship:SHOUTED]->(node {id: $userId2}) WHERE relationship.createdAt IS NOT NULL RETURN relationship', - { userId1: 'current-user-id', userId2: 'another-user-post-id' }, + const relation = await instance.cypher( + 'MATCH (user:User {id: $userId1})-[relationship:SHOUTED]->(node {id: $userId2}) WHERE relationship.createdAt IS NOT NULL RETURN relationship', + { + userId1: 'current-user-id', + userId2: 'another-user-post-id', + } + ) + const relationshipProperties = relation.records.map( + record => record.get('relationship').properties.createdAt ) - const relationshipProperties = relation.records.map(record => record.get('relationship').properties.createdAt) expect(relationshipProperties[0]).toEqual(expect.any(String)) - }) it('can not shout my own post', async () => {