refactor: column test

This commit is contained in:
scarf 2025-03-27 02:02:49 +09:00
parent 98e87c38a4
commit 4c12edbdb4
No known key found for this signature in database
GPG Key ID: 07CA0A3CCA037E7D

View File

@ -9,17 +9,29 @@ describe('<Column />', () => {
it('runs the scroll animation if the column contains scrollable content', () => {
const scrollToMock = jest.fn();
const { container } = render(
<Column heading='notifications' icon='notifications' iconComponent={fakeIcon}>
<Column
heading='notifications'
icon='notifications'
iconComponent={fakeIcon}
>
<div className='scrollable' />
</Column>,
);
container.querySelector('.scrollable').scrollTo = scrollToMock;
const scrollable = container.querySelector('.scrollable');
if (scrollable?.scrollTo) scrollable.scrollTo = scrollToMock;
fireEvent.click(screen.getByText('notifications'));
expect(scrollToMock).toHaveBeenCalledWith({ behavior: 'smooth', top: 0 });
});
it('does not try to scroll if there is no scrollable content', () => {
render(<Column heading='notifications' icon='notifications' iconComponent={fakeIcon} />);
render(
<Column
heading='notifications'
icon='notifications'
iconComponent={fakeIcon}
/>,
);
fireEvent.click(screen.getByText('notifications'));
});
});