mirror of
https://github.com/mastodon/mastodon.git
synced 2025-05-07 20:26:15 +00:00
refactor: column test
This commit is contained in:
parent
98e87c38a4
commit
4c12edbdb4
|
@ -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'));
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user