/**
 * @jest-environment jsdom
 */

import * as React from 'react';
import 'jest-canvas-mock';
import { render } from '@testing-library/react';

import {
    COMPONENT_MODE_INITIAL,
    COMPONENT_MODE_LOADING,
    COMPONENT_MODE_ERROR,
    COMPONENT_MODE_EMPTY,
    COMPONENT_MODE_OK,
    ComponentModeWindow,
} from '../../../src/ts';

describe('ComponentModeWindow', () => {
    test('COMPONENT_MODE_INITIAL', () => {
        const { container } = render(
            <ComponentModeWindow mode={COMPONENT_MODE_INITIAL} />
        );
        expect(container.firstChild).toBeFalsy();
    });

    test('COMPONENT_MODE_OK', () => {
        const { container } = render(
            <ComponentModeWindow mode={COMPONENT_MODE_OK} />
        );
        expect(container.firstChild).toBeFalsy();
    });

    test('COMPONENT_MODE_OK', () => {
        const { getByAltText } = render(
            <ComponentModeWindow mode={COMPONENT_MODE_LOADING} />
        );
        expect(getByAltText('Loading')).toBeTruthy();
    });

    test('COMPONENT_MODE_ERROR', () => {
        const { getByText } = render(
            <ComponentModeWindow
                mode={COMPONENT_MODE_ERROR}
                hasErrorMode={true}
            />
        );
        expect(getByText('Something went wrong on our end')).toBeTruthy();
    });

    test('COMPONENT_MODE_EMPTY', () => {
        const { getByText } = render(
            <ComponentModeWindow
                mode={COMPONENT_MODE_EMPTY}
                hasEmptyMode={true}
            />
        );
        expect(
            getByText('No data available based on your selections')
        ).toBeTruthy();
    });
});
