Skip to content

Commit

Permalink
added test for get user by username
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidCG-27 committed Mar 9, 2025
1 parent f19eb5e commit 0cc9465
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion users/userservice/user-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,19 @@ describe('User Service', () => {
);
});


it('should get a specific user on GET /getUser/:username', async () => {
const hashedPassword = await bcrypt.hash('securepassword', 10);
await User.create({ username: 'specificUser', password: hashedPassword });

const response = await request(app).get('/getUser/specificUser');
expect(response.status).toBe(200);
expect(response.body).toHaveProperty('username', 'specificUser');
});

it('should return 404 if user not found on GET /getUser/:username', async () => {
const response = await request(app).get('/getUser/nonexistentUser');
expect(response.status).toBe(404);
expect(response.body).toHaveProperty('error', 'Usuario no encontrado');
});

});

0 comments on commit 0cc9465

Please sign in to comment.