import { render } from '@testing-library/react';
import React from 'react';
import { describe, expect, it } from 'vitest';
import { FormElementContainer } from './FormElementContainer';

describe('FormElementContainer', () => {
  const mockLabel = 'mockLabel';

  it('renders the component without crashing', () => {
    const { container } = render(<FormElementContainer label={mockLabel} />);

    expect(container).toBeTruthy();
  });

  it('displays a label', () => {
    const { container } = render(<FormElementContainer label={mockLabel} />);

    const label = container.querySelector('label');

    expect(label?.textContent).toBe(mockLabel);
  });

  it('check label display, when inlineMode is false by default', () => {
    const { container } = render(<FormElementContainer label={mockLabel} />);

    const label = container.querySelector('label');

    expect(label).toBeInTheDocument();
  });

  it('check label hide, when inlineMode is true', () => {
    const { container } = render(
      <FormElementContainer label={mockLabel} inlineMode={true} />,
    );

    const label = container.querySelector('label');

    expect(label).not.toBeInTheDocument();
  });
});
