Skip to content

Commit

Permalink
✅ test: add mouse movement test
Browse files Browse the repository at this point in the history
  • Loading branch information
Bear29ers committed Apr 20, 2024
1 parent d105cd0 commit f68a28d
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/components/Cursor/Cursor.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { screen, render } from '@testing-library/react';
import { screen, render, fireEvent, waitFor } from '@testing-library/react';
import '@testing-library/jest-dom';

import Cursor from './Cursor';
Expand All @@ -20,4 +20,25 @@ describe('src/components/Cursor/Cursor.test.tsx', () => {
const cursorElement = screen.getByTestId('cursor');
expect(cursorElement).toBeInTheDocument();
});

it('should render the Cursor component with mouse movement', async () => {
const cursorElement = screen.getByTestId('cursor');
const initialPosition = {
x: cursorElement.style.left,
y: cursorElement.style.top,
};

fireEvent.mouseMove(document, {
clientX: 100,
clinetY: 200,
});

await waitFor(() => {
expect(cursorElement.style.left).not.toBe(initialPosition.x);
});

await waitFor(() => {
expect(cursorElement.style.top).not.toBe(initialPosition.y);
});
});
});

0 comments on commit f68a28d

Please sign in to comment.