import React from 'react';
import { screen } from '@testing-library/react';
import { renderInAppContext } from '@theorchard/suite-testing';

import {
    RunTimerWithStatus,
    RunTimerWithStatusProps,
} from 'src/components/shared/run-timer-with-status';

describe('<RunTimerWithStatus>', () => {
    const defaultProps: RunTimerWithStatusProps = {
        avgRunTime: 100,
        p95RunningTime: 200,
        displayText: 'STATUS',
    };

    const render = (props: RunTimerWithStatusProps = defaultProps) =>
        renderInAppContext(<RunTimerWithStatus {...props} />);

    it('renders with default props', async () => {
        render();

        const tooltip = screen.getByTestId('RunTimerWithStatus');

        expect(tooltip).toHaveTextContent('STATUS');
    });

    it('renders with a specific `testId`', () => {
        render({
            ...defaultProps,
            testId: 'CustomRunTimerWithStatus',
        });

        const tooltip = screen.getByTestId('CustomRunTimerWithStatus');

        expect(tooltip).toHaveTextContent('STATUS');
    });
});
