feat: add tests for mark all as read (backend)

This commit is contained in:
Ademílson F. Tonato 2020-10-24 19:38:45 +01:00
parent e37fb535dc
commit 1df69c90fd

View File

@ -393,4 +393,51 @@ describe('given some notifications', () => {
})
})
})
describe('markAllAsRead', () => {
const markAllAsReadMutation = gql`
mutation {
markAllAsRead {
from {
__typename
... on Post {
content
}
... on Comment {
content
}
}
read
createdAt
}
}
`
describe('unauthenticated', () => {
it('throws authorization error', async () => {
const result = await mutate({
mutation: markAllAsReadMutation,
})
expect(result.errors[0]).toHaveProperty('message', 'Not Authorised!')
})
})
describe('authenticated', () => {
beforeEach(async () => {
authenticatedUser = await user.toJson()
})
describe('not being notified at all', () => {
beforeEach(async () => {
variables = {
...variables,
}
})
it('returns undefined', async () => {
const response = await mutate({ mutation: markAllAsReadMutation, variables })
expect(response.data.markAsRead).toEqual(undefined)
expect(response.errors).toBeUndefined()
})
})
})
})
})