import { cleanup } from '@testing-library/react';
import { render } from '../../utils/theme-render-wrapper';

import { ASSETS_URL } from '../../consts/common';
import { CustomIcon } from './custom-icon';
import type { CustomIconProps } from './types';

afterEach(cleanup);

const mockIcon: CustomIconProps = {
  src: `${ASSETS_URL}/icons/icon_database.svg`,
  title: 'Database'
};

describe('<CustomIcon />', () => {
  it(`should render successfully`, () => {
    const { baseElement } = render(<CustomIcon {...mockIcon} />);
    expect(baseElement).toBeTruthy();
  });

  it(`should render large icon with default colors`, () => {
    const { baseElement } = render(<CustomIcon {...mockIcon} color="" size="large" />);
    expect(baseElement).toBeTruthy();
  });

  it(`should render small icon with inherited colors`, () => {
    const { baseElement } = render(<CustomIcon {...mockIcon} color="inherit" size={undefined} />);
    expect(baseElement).toBeTruthy();
  });

  it(`should render a rotated custom sized icon`, () => {
    const { baseElement } = render(<CustomIcon {...mockIcon} customSize={64} rotateDeg={-90} />);
    expect(baseElement).toBeTruthy();
  });
});
