Skip to content

Commit

Permalink
Merge pull request #367 from Arquisoft/laura
Browse files Browse the repository at this point in the history
aumento coverage en micro ranking y en game
  • Loading branch information
uo277310 authored Apr 23, 2024
2 parents 3b9f42f + c8bb975 commit a06b121
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
35 changes: 35 additions & 0 deletions users/rankingservice/ranking-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,39 @@ it('should return 400 if user does not exist', async () => {
expect(deletedUserRank).not.toBeNull(); // Expect the user rank to still exist
});

describe('GET /obtainRank', () => {
it('it should GET all the rankings', async () => {
const response = await request(app).get('/obtainRank');
expect(response.status).toBe(200);
expect(Array.isArray(response.body)).toBe(true);
});
});

describe('POST /updateAllRanking', () => {
it('it should update all rankings', async () => {
const rankingData = [
{
username: 'testUser1',
preguntasCorrectas: 5,
preguntasFalladas: 3,
numPartidas: 1
},
{
username: 'testUser2',
preguntasCorrectas: 7,
preguntasFalladas: 2,
numPartidas: 1
}
];

const response = await request(app)
.post('/updateAllRanking')
.send(rankingData);

expect(response.status).toBe(200);
expect(response.body).toHaveProperty('message', 'Rankings actualizados correctamente.');
});
});


});
17 changes: 17 additions & 0 deletions webapp/src/components/Game.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { render, screen, waitFor } from '@testing-library/react';
import Game from './Game';

describe('Game component', () => {
test('renders without crashing', () => {
render(<Game username="testUser" totalQuestions={10} timeLimit={180} themes={{}} />);
expect(screen.getByText(/Pregunta Número 1/i)).toBeInTheDocument();
});

test('displays time remaining', () => {
render(<Game username="testUser" totalQuestions={10} timeLimit={180} themes={{}} />);
expect(screen.getByText(/¡Tiempo restante 03:00!/i)).toBeInTheDocument();
});



});

0 comments on commit a06b121

Please sign in to comment.