Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: move UE act test to UE press tests
  • Loading branch information
mdjastrzebski committed Oct 23, 2023
commit dd7d2f9804be98c8bff938938f8c514af08d7bae
35 changes: 0 additions & 35 deletions src/user-event/__tests__/act.test.tsx

This file was deleted.

28 changes: 28 additions & 0 deletions src/user-event/press/__tests__/press.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -454,4 +454,32 @@ describe('userEvent.press with fake timers', () => {

expect(mockOnPress).toHaveBeenCalled();
});

test('disables act environmennt', async () => {
// In this test there is state update during await when typing
// Since wait is not wrapped by act there would be a warning
// if act environment was not disabled.
const consoleErrorSpy = jest.spyOn(console, 'error');
jest.useFakeTimers();

const TestComponent = () => {
const [showText, setShowText] = React.useState(false);

React.useEffect(() => {
setTimeout(() => setShowText(true), 100);
}, []);

return (
<>
<Pressable testID="pressable" />
{showText && <Text />}
</>
);
};

render(<TestComponent />);
await userEvent.press(screen.getByTestId('pressable'));

expect(consoleErrorSpy).not.toHaveBeenCalled();
});
});