import React from 'react';
import { fireEvent, render } from '@testing-library/react';
import { noop } from 'lodash';
import SplashPage from '../splash-page';

describe('<SplashPage>', () => {
    it('scrolls when "back to top" button is clicked', () => {
        const scrollToSpy = jest.spyOn(window, 'scrollTo').mockImplementation(noop);

        const { getByText } = render(<SplashPage />);

        const backToTopButton = getByText('labels.backToTop');
        fireEvent.click(backToTopButton);

        expect(scrollToSpy).toHaveBeenCalledWith(0, 0);

        scrollToSpy.mockRestore();
    });
});
