{"size": 1850, "ext": "js", "max_stars_repo_path": "packages/sources/svelte/src/components/actions/VtmnDropdown/test/VtmnDropdown.spec.js", "max_stars_repo_name": "0x2A-git/vitamin-web", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/sources/svelte/src/components/actions/VtmnDropdown/test/VtmnDropdown.spec.js", "max_issues_repo_name": "0x2A-git/vitamin-web", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/sources/svelte/src/components/actions/VtmnDropdown/test/VtmnDropdown.spec.js", "max_forks_repo_name": "0x2A-git/vitamin-web", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.90625, "max_line_length": 77, "alphanum_fraction": 0.6210810811}
import { render } from '@testing-library/svelte';
import VtmnDropdownWithSlots from './VtmnDropdownWithSlots.svelte';

describe('VtmnDropdown', () => {
  test('Should display the dropdown', () => {
    const { container } = render(VtmnDropdownWithSlots, {
      label: 'Label',
      summary: 'Default label',
      id: 'dropdown-unit-test',
    });

    expect(container).toBeInTheDocument();
  });

  test('Should render the main label', () => {
    const { getByText } = render(VtmnDropdownWithSlots, {
      label: 'Label',
      summary: 'Default label',
      id: 'dropdown-unit-test',
    });

    expect(getByText('Label')).toBeVisible();
    expect(getByText('Label').tagName).toEqual('LABEL');
    expect(getByText('Label')).toHaveAttribute('id', 'dropdown-unit-test');
  });

  test('Should render the summary', () => {
    const { getByText } = render(VtmnDropdownWithSlots, {
      label: 'Label',
      summary: 'Default label',
      id: 'dropdown-unit-test',
    });

    expect(getByText('Default label')).toBeVisible();
    expect(getByText('Default label').tagName).toEqual('SUMMARY');
    expect(getByText('Default label')).toHaveAttribute(
      'aria-labelledby',
      'dropdown-unit-test',
    );
  });

  test('Shoudl apply custom css class', () => {
    const { container } = render(VtmnDropdownWithSlots, {
      label: 'Label',
      summary: 'Default label',
      id: 'dropdown-unit-test',
      class: 'custom-class',
    });

    expect(container.getElementsByClassName('custom-class')).toHaveLength(1);
  });

  test('Should disable the dropdown', () => {
    const { container } = render(VtmnDropdownWithSlots, {
      label: 'Label',
      summary: 'Default label',
      id: 'dropdown-unit-test',
      disabled: true,
    });

    expect(container.querySelector('[aria-disabled="true"]')).toBeTruthy();
  });
});
