Added a test

This commit is contained in:
JubaAzul 2025-03-18 14:37:52 -04:00
parent a0f53232cd
commit 4b4a995a4e
2 changed files with 26 additions and 1 deletions

View file

@ -92,4 +92,29 @@ describe('LiveResults', () => {
expect(mockShowSelectedQuestion).toHaveBeenCalled(); expect(mockShowSelectedQuestion).toHaveBeenCalled();
}); });
test('toggles the visibility of content when the arrow button is clicked', () => {
render(<LiveResults
socket={null}
questions={mockQuestions}
showSelectedQuestion={mockShowSelectedQuestion}
quizMode="teacher"
students={mockStudents}
/>);
expect(screen.queryByText('Afficher les noms')).toBeInTheDocument();
expect(screen.queryByText('Afficher les réponses')).toBeInTheDocument();
expect(screen.queryByTestId('table-container')).toBeInTheDocument();
const toggleButton = screen.getByRole('button', { name: /toggle visibility/i });
fireEvent.click(toggleButton);
expect(screen.queryByText('Afficher les noms')).not.toBeInTheDocument();
expect(screen.queryByText('Afficher les réponses')).not.toBeInTheDocument();
expect(screen.queryByTestId('table-container')).not.toBeInTheDocument();
fireEvent.click(toggleButton);
expect(screen.queryByText('Afficher les noms')).toBeInTheDocument();
expect(screen.queryByText('Afficher les réponses')).toBeInTheDocument();
expect(screen.queryByTestId('table-container')).toBeInTheDocument();
});
}); });

View file

@ -71,7 +71,7 @@ const LiveResults: React.FC<LiveResultsProps> = ({ questions, showSelectedQuesti
)} )}
</div> </div>
{isExpanded && ( {isExpanded && (
<div className="table-container"> <div className="table-container" data-testid="table-container">
<LiveResultsTable <LiveResultsTable
students={students} students={students}