import { getItem } from '../helpers';
import { InfoCircleOutlined } from '@ant-design/icons';

describe('Checking the function for the validity of the returned object', () => {
  test('Returning key and label as string', () => {
    const data = getItem('Assets', 'assets');
    expect(data).toEqual({ label: 'Assets', key: 'assets' });
  });
  test('Returning key and label as a Node element', () => {
    const data = getItem(<div>Assets</div>, 'assets');
    expect(data).toEqual({
      label: <div>Assets</div>,
      key: 'assets',
    });
  });
  test('Returning key and label as string with icon', () => {
    const data = getItem('Assets', 'assets', <InfoCircleOutlined />);
    expect(data).toEqual({
      label: 'Assets',
      key: 'assets',
      icon: <InfoCircleOutlined />,
    });
  });
  test('Returning object is not equal to input parameters', () => {
    const data = getItem(<div>Assets</div>, 'rotation', <InfoCircleOutlined />);
    expect(data).not.toEqual({
      label: <div>Assets</div>,
      key: 'assets',
    });
  });
  test('Returning key and label as string with icon and children', () => {
    const data = getItem('Assets', 'assets', <InfoCircleOutlined />, false, [
      getItem('Assets', 'assets', <InfoCircleOutlined />),
    ]);
    expect(data).toEqual({
      label: 'Assets',
      key: 'assets',
      icon: <InfoCircleOutlined />,
      disabled: false,
      children: [
        {
          label: 'Assets',
          key: 'assets',
          icon: <InfoCircleOutlined />,
        },
      ],
    });
  });
  test('Returning key and label as Node elements with icon and children', () => {
    const data = getItem(
      <div>Assets</div>,
      'rotation',
      <InfoCircleOutlined />,
      false,
      [getItem(<div>Assets</div>, 'rotation', <InfoCircleOutlined />)],
    );
    expect(data).not.toEqual({
      label: <div>Assets</div>,
      key: 'assets',
      icon: <InfoCircleOutlined />,
      disabled: false,
      children: [
        {
          label: <div>Assets</div>,
          key: 'assets',
          icon: <InfoCircleOutlined />,
        },
      ],
    });
  });
  test('Returning key and label as Node elements with icon and children not equal input parameters', () => {
    const data = getItem(
      <div>Assets</div>,
      'assets',
      <InfoCircleOutlined />,
      false,
      [getItem(<div>Assets</div>, 'assets', <InfoCircleOutlined />)],
    );
    expect(data).not.toEqual({
      label: <div>Assets</div>,
      key: 'rotation',
      icon: <InfoCircleOutlined />,
      disabled: false,
      children: [
        {
          label: <div>Assets</div>,
          key: 'rotation',
          icon: <InfoCircleOutlined />,
        },
      ],
    });
  });
});
