mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 16:04:23 +00:00
Update tests to handle asynchronous loading and initialization states across multiple components
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
screen,
|
||||
fireEvent,
|
||||
waitFor,
|
||||
act,
|
||||
} from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import { MantineProvider } from '@mantine/core';
|
||||
@@ -192,7 +193,7 @@ describe('DeleteAccountModal', () => {
|
||||
expect(mockOnConfirm).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('handles rapid multiple clicks gracefully', () => {
|
||||
it('handles rapid multiple clicks gracefully', async () => {
|
||||
render(
|
||||
<DeleteAccountModal
|
||||
opened={true}
|
||||
@@ -207,12 +208,16 @@ describe('DeleteAccountModal', () => {
|
||||
fireEvent.change(passwordInput, { target: { value: 'testpassword' } });
|
||||
|
||||
// Multiple rapid clicks should not break the component
|
||||
fireEvent.click(deleteButton);
|
||||
fireEvent.click(deleteButton);
|
||||
fireEvent.click(deleteButton);
|
||||
act(() => {
|
||||
fireEvent.click(deleteButton);
|
||||
fireEvent.click(deleteButton);
|
||||
fireEvent.click(deleteButton);
|
||||
});
|
||||
|
||||
expect(screen.getByText('Delete Account')).toBeInTheDocument();
|
||||
expect(mockOnConfirm).toHaveBeenCalledWith('testpassword');
|
||||
await waitFor(() => {
|
||||
expect(mockOnConfirm).toHaveBeenCalledWith('testpassword');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user