Fixed formatting

This commit is contained in:
Kapil Jain 2019-10-17 19:45:39 -04:00
parent f6e70bee25
commit 202316e0a3
2 changed files with 63 additions and 62 deletions

View File

@ -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,
})
})
})
})
})

View File

@ -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 () => {