fix requestIdleCallback again

This commit is contained in:
ChaosExAnima 2025-04-14 17:25:58 +02:00
parent e50ab94e8f
commit fd0821e889
No known key found for this signature in database
GPG Key ID: 8F2B333100FB6117
2 changed files with 9 additions and 4 deletions

View File

@ -7,9 +7,6 @@ const fakeIcon = () => <span />;
describe('<Column />', () => {
describe('<ColumnHeader /> click handler', () => {
it('runs the scroll animation if the column contains scrollable content', () => {
vi.useFakeTimers({
toFake: ['requestIdleCallback']
});
const scrollToMock = vi.fn();
const { container } = render(
<Column heading='notifications' icon='notifications' iconComponent={fakeIcon}>
@ -18,7 +15,6 @@ describe('<Column />', () => {
);
container.querySelector('.scrollable').scrollTo = scrollToMock;
fireEvent.click(screen.getByText('notifications'));
vi.runAllTimers();
expect(scrollToMock).toHaveBeenCalledWith({ behavior: 'smooth', top: 0 });
});

View File

@ -7,6 +7,15 @@ import { render as rtlRender } from '@testing-library/react';
import { IdentityContext } from './identity_context';
beforeAll(() => {
global.requestIdleCallback = vi.fn((cb: IdleRequestCallback) => {
// @ts-expect-error IdleRequestCallback expects an argument of type IdleDeadline,
// but that doesn't exist in this environment.
cb();
return 0;
});
});
function render(
ui: React.ReactElement,
{