15 lines
437 B
TypeScript
15 lines
437 B
TypeScript
import { render } from '@testing-library/react';
|
|
import { act } from '@testing-library/react';
|
|
import ScrollIntoView from '../../../../../src/components/ScrollIntoView';
|
|
|
|
test('scrolls the element into view on render', () => {
|
|
const scrollMock = jest.fn();
|
|
HTMLElement.prototype.scrollIntoView = scrollMock;
|
|
|
|
act(() => {
|
|
render(<ScrollIntoView />);
|
|
});
|
|
|
|
expect(scrollMock).toHaveBeenCalledWith({ behavior: 'smooth' });
|
|
});
|