Skip to content
Snippets Groups Projects
Commit 1f8c43d3 authored by Sebastian's avatar Sebastian
Browse files

feat(component-invite): fix tests

parent 0fce853b
No related branches found
No related tags found
No related merge requests found
...@@ -42,21 +42,6 @@ describe('Delete Collections Invitations route handler', () => { ...@@ -42,21 +42,6 @@ describe('Delete Collections Invitations route handler', () => {
const data = JSON.parse(res._getData()) const data = JSON.parse(res._getData())
expect(data.error).toEqual('Invitation invalid-id not found') expect(data.error).toEqual('Invitation invalid-id not found')
}) })
it('should return an error when the request user is not editorInChief or admin', async () => {
const { user } = testFixtures.users
const { collection } = testFixtures.collections
const req = httpMocks.createRequest()
req.params.collectionId = collection.id
req.params.invitationId = collection.invitations[0].id
req.user = user.id
const res = httpMocks.createResponse()
await require(deletePath)(models)(req, res)
expect(res.statusCode).toBe(403)
const data = JSON.parse(res._getData())
expect(data.error).toEqual(
'The request user must be Editor in Chief or Admin',
)
})
it('should return success when the collection and invitation exist', async () => { it('should return success when the collection and invitation exist', async () => {
const { editorInChief } = testFixtures.users const { editorInChief } = testFixtures.users
const { collection } = testFixtures.collections const { collection } = testFixtures.collections
......
...@@ -40,7 +40,7 @@ describe('Get collection invitations route handler', () => { ...@@ -40,7 +40,7 @@ describe('Get collection invitations route handler', () => {
await require(getPath)(models)(req, res) await require(getPath)(models)(req, res)
expect(res.statusCode).toBe(400) expect(res.statusCode).toBe(400)
const data = JSON.parse(res._getData()) const data = JSON.parse(res._getData())
expect(data.error).toEqual('User ID and Role are required') expect(data.error).toEqual('Role is required')
}) })
it('should return an error when the collection does not exist', async () => { it('should return an error when the collection does not exist', async () => {
const { editorInChief, handlingEditor } = testFixtures.users const { editorInChief, handlingEditor } = testFixtures.users
...@@ -96,23 +96,4 @@ describe('Get collection invitations route handler', () => { ...@@ -96,23 +96,4 @@ describe('Get collection invitations route handler', () => {
`The requested collection does not have a ${req.query.role} Team`, `The requested collection does not have a ${req.query.role} Team`,
) )
}) })
it('should return an error when the request user is not EiC or Admin', async () => {
const { user, handlingEditor } = testFixtures.users
const { collection } = testFixtures.collections
const req = httpMocks.createRequest()
req.query = {
role: 'handlingEditor',
userId: handlingEditor.id,
}
req.params.collectionId = collection.id
req.user = user.id
const res = httpMocks.createResponse()
const models = Model.build()
await require(getPath)(models)(req, res)
expect(res.statusCode).toBe(403)
const data = JSON.parse(res._getData())
expect(data.error).toEqual(
`The request user must be Editor in Chief or Admin`,
)
})
}) })
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment