+ await command.update({ abuseId, body })
+ })
+ })
+
+ describe('When creating an abuse message', function () {
+ const message = 'my super message'
+
+ it('Should fail with an invalid abuse id', async function () {
+ await command.addMessage({ token: userToken2, abuseId: 888, message, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ })
+
+ it('Should fail with a non authenticated user', async function () {
+ await command.addMessage({ token: 'fake_token', abuseId, message, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ })
+
+ it('Should fail with an invalid logged in user', async function () {
+ await command.addMessage({ token: userToken2, abuseId, message, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ })
+
+ it('Should fail with an invalid message', async function () {
+ await command.addMessage({ token: userToken, abuseId, message: 'a'.repeat(5000), expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ })
+
+ it('Should suceed with the correct params', async function () {
+ const res = await command.addMessage({ token: userToken, abuseId, message })
+ messageId = res.body.abuseMessage.id
+ })
+ })
+
+ describe('When listing abuse messages', function () {
+
+ it('Should fail with an invalid abuse id', async function () {
+ await command.listMessages({ token: userToken, abuseId: 888, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ })
+
+ it('Should fail with a non authenticated user', async function () {
+ await command.listMessages({ token: 'fake_token', abuseId, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ })
+
+ it('Should fail with an invalid logged in user', async function () {
+ await command.listMessages({ token: userToken2, abuseId, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ })
+
+ it('Should succeed with the correct params', async function () {
+ await command.listMessages({ token: userToken, abuseId })
+ })
+ })
+
+ describe('When deleting an abuse message', function () {
+ it('Should fail with an invalid abuse id', async function () {
+ await command.deleteMessage({ token: userToken, abuseId: 888, messageId, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ })
+
+ it('Should fail with an invalid message id', async function () {
+ await command.deleteMessage({ token: userToken, abuseId, messageId: 888, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ })
+
+ it('Should fail with a non authenticated user', async function () {
+ await command.deleteMessage({ token: 'fake_token', abuseId, messageId, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ })
+
+ it('Should fail with an invalid logged in user', async function () {
+ await command.deleteMessage({ token: userToken2, abuseId, messageId, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ })
+
+ it('Should succeed with the correct params', async function () {
+ await command.deleteMessage({ token: userToken, abuseId, messageId })