From d02630e9a4142792c2341258d06b9bc8d4a30d17 Mon Sep 17 00:00:00 2001 From: Laura Cordero Date: Wed, 24 Apr 2024 13:09:19 +0200 Subject: [PATCH] =?UTF-8?q?Test=20de=20usuario=20vac=C3=ADo=20y=20contrase?= =?UTF-8?q?=C3=B1a=20vacios=20en=20login?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- users/authservice/auth-service.test.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/users/authservice/auth-service.test.js b/users/authservice/auth-service.test.js index 7b55ee72..0c859352 100644 --- a/users/authservice/auth-service.test.js +++ b/users/authservice/auth-service.test.js @@ -42,4 +42,27 @@ describe('Auth Service', () => { expect(response.status).toBe(200); expect(response.body).toHaveProperty('username', 'testuser'); }); + + it('should return 400 if username is empty or blank', async () => { + const userError1 = { + username: ' ', + password: 'testpassword', + }; + + const response = await request(app).post('/login').send(userError1); + expect(response.status).toBe(400); + expect(response.body).toHaveProperty('error', 'El nombre de usuario no puede estar vacío'); + }); + + it('should return 400 if password is empty or blank', async () => { + const userError2 = { + username: 'testusername', + password: ' ', + }; + + const response = await request(app).post('/login').send(userError2); + expect(response.status).toBe(400); + expect(response.body).toHaveProperty('error', 'La contraseña no puede estar vacía'); + }); + });