Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aumento coverage en micro ranking y en game #367

Merged
merged 17 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});



});