Skip to content

Commit

Permalink
Test de usuario vacío y contraseña vacios en login
Browse files Browse the repository at this point in the history
  • Loading branch information
lauracc97 committed Apr 24, 2024
1 parent 222e456 commit d02630e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions users/authservice/auth-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

});

0 comments on commit d02630e

Please sign in to comment.