Skip to content

Commit

Permalink
Merge pull request #100 from Arquisoft/laura
Browse files Browse the repository at this point in the history
añadido test de get usuarios
  • Loading branch information
uo277310 authored Mar 6, 2024
2 parents 3515ab3 + e96ec26 commit 0947071
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions users/userservice/user-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,31 @@ describe('User Service', () => {
expect(response.status).toBe(200);
expect(response.body).toHaveProperty('username', 'testuser');
});



//prueba get
it('should get all users on GET /getAllUsers', async () => {

// Agrego primero usuarios
await request(app).post('/adduser').send({
username: 'testuser',
password: 'testpassword',
});

await request(app).post('/adduser').send({
username: 'testuser2',
password: 'testpassword2',

});
// llamo al get
const response = await request(app).get('/getAllUsers');
expect(response.status).toBe(200);
expect(response.body).toBeInstanceOf(Array);//obtengo elementos
// miro que esten los dos añadidos
const usernames = response.body.map(user => user.username);
expect(usernames).toContain('testuser');
expect(usernames).toContain('testuser2');

});
});

0 comments on commit 0947071

Please sign in to comment.