From aa128ab122360d9dfb3e55ab4029e7e27fdbe663 Mon Sep 17 00:00:00 2001 From: Laura Cordero Date: Wed, 24 Apr 2024 13:32:15 +0200 Subject: [PATCH] Completing test --- users/authservice/auth-service.test.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/users/authservice/auth-service.test.js b/users/authservice/auth-service.test.js index 0c859352..0bc2c026 100644 --- a/users/authservice/auth-service.test.js +++ b/users/authservice/auth-service.test.js @@ -65,4 +65,25 @@ describe('Auth Service', () => { expect(response.body).toHaveProperty('error', 'La contraseña no puede estar vacía'); }); + it('should return 401 if username or password is incorrect', async () => { + const userError3 = { + username: 'wrongusername', + password: 'wrongpassword', + + }; + + const response = await request(app).post('/login').send(userError3); + expect(response.status).toBe(401); + expect(response.body).toHaveProperty('error', 'Credenciales inválidas'); + }); + + it('should return 500 if there is a server error', async () => { + const userError4 = { + username: 'wrongFormat', + }; + + const response = await request(app).post('/login').send(userError4); + expect(response.status).toBe(500); + expect(response.body).toHaveProperty('error', 'Internal Server Error'); + }); });