mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
ajout tests de participation et bonne reponses
This commit is contained in:
parent
aaf262db2a
commit
ed5bd2988f
1 changed files with 63 additions and 1 deletions
|
|
@ -104,7 +104,8 @@ test('calculates and displays the correct student grades', () => {
|
||||||
// Check if the student grades are calculated and displayed correctly
|
// Check if the student grades are calculated and displayed correctly
|
||||||
mockStudents.forEach((student) => {
|
mockStudents.forEach((student) => {
|
||||||
const grade = student.answers.filter(answer => answer.isCorrect).length / mockQuestions.length * 100;
|
const grade = student.answers.filter(answer => answer.isCorrect).length / mockQuestions.length * 100;
|
||||||
expect(screen.getByText(`${grade.toFixed()} %`)).toBeInTheDocument();
|
let foundArray = screen.queryAllByText(`${grade.toFixed()} %`);
|
||||||
|
expect(foundArray[0]).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -139,6 +140,67 @@ test('calculates and displays the class average', () => {
|
||||||
expect(classAverageElement).toBeInTheDocument();
|
expect(classAverageElement).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('calculates and displays the total correct answers', () => {
|
||||||
|
render(
|
||||||
|
<LiveResults
|
||||||
|
socket={mockSocket}
|
||||||
|
questions={mockQuestions}
|
||||||
|
showSelectedQuestion={jest.fn()}
|
||||||
|
quizMode="teacher"
|
||||||
|
students={mockStudents}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
// Toggle the display of usernames
|
||||||
|
const toggleUsernamesSwitch = screen.getByLabelText('Afficher les noms');
|
||||||
|
|
||||||
|
// Toggle the display of usernames back
|
||||||
|
fireEvent.click(toggleUsernamesSwitch);
|
||||||
|
|
||||||
|
// Calculate the class average
|
||||||
|
const totalCorrectAnswers = mockStudents.reduce((total, student) => {
|
||||||
|
return total + (student.answers.filter(answer => answer.isCorrect).length);
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
// Check if the class average is displayed correctly
|
||||||
|
const classTotalElements = screen.getAllByText(`${totalCorrectAnswers.toFixed()}`);
|
||||||
|
const classAverageElement = classTotalElements.find((element) => {
|
||||||
|
return element.closest('td')?.classList.contains('MuiTableCell-footer');
|
||||||
|
});
|
||||||
|
expect(classAverageElement).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('calculates and displays the total participation', () => {
|
||||||
|
render(
|
||||||
|
<LiveResults
|
||||||
|
socket={mockSocket}
|
||||||
|
questions={mockQuestions}
|
||||||
|
showSelectedQuestion={jest.fn()}
|
||||||
|
quizMode="teacher"
|
||||||
|
students={mockStudents}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
// Toggle the display of usernames
|
||||||
|
const toggleUsernamesSwitch = screen.getByLabelText('Afficher les noms');
|
||||||
|
|
||||||
|
// Toggle the display of usernames back
|
||||||
|
fireEvent.click(toggleUsernamesSwitch);
|
||||||
|
|
||||||
|
// Calculate the class average
|
||||||
|
const totalGrades = mockStudents.reduce((total, student) => {
|
||||||
|
return total + (student.answers.filter(answer => answer.isCorrect).length / mockQuestions.length * 100);
|
||||||
|
}, 0);
|
||||||
|
const totalParticipation = totalGrades / mockStudents.length;
|
||||||
|
|
||||||
|
// Check if the class average is displayed correctly
|
||||||
|
const totalElements = screen.getAllByText(`${totalParticipation.toFixed()} %`);
|
||||||
|
const allTotalElement = totalElements.find((element) => {
|
||||||
|
return element.closest('td')?.classList.contains('MuiTableCell-footer');
|
||||||
|
});
|
||||||
|
expect(allTotalElement).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
test('displays the correct answers per question', () => {
|
test('displays the correct answers per question', () => {
|
||||||
render(
|
render(
|
||||||
<LiveResults
|
<LiveResults
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue