import React from 'react';
import { screen } from '@testing-library/react';
import { renderInAppContext } from '@theorchard/suite-testing';
import ReadError, { INTL_CLASSNAME } from 'src/components/errors/read-error';

const renderComponent = () =>
    renderInAppContext(<ReadError error={{ message: 'error text' }} />);

describe('ReadError', () => {
    test('Renders component', () => {
        const consoleSpy = jest.spyOn(console, 'log');

        renderComponent();

        expect(
            screen.getAllByText($t(`${INTL_CLASSNAME}.texts.somethingWrong`))
        ).toHaveLength(1);
        expect(
            screen.getAllByText($t(`${INTL_CLASSNAME}.texts.couldNotFind`))
        ).toHaveLength(1);
        expect(
            screen.getAllByText($t(`${INTL_CLASSNAME}.texts.tryAgain`))
        ).toHaveLength(1);

        expect(consoleSpy).toHaveBeenCalledWith('error text');
    });
});
