{"size": 1066, "ext": "js", "max_stars_repo_path": "src/components/ActionMenu/ItemTemplates/Default.test.js", "max_stars_repo_name": "folio-org/ui-catload", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/ActionMenu/ItemTemplates/Default.test.js", "max_issues_repo_name": "folio-org/ui-catload", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/ActionMenu/ItemTemplates/Default.test.js", "max_forks_repo_name": "folio-org/ui-catload", "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": 24.2272727273, "max_line_length": 91, "alphanum_fraction": 0.6350844278}
import React from 'react';
import { fireEvent } from '@testing-library/react';

import { renderWithIntl } from '@folio/stripes-data-transfer-components/test/jest/helpers';

import '../../../../test/jest/__mock__';
import { translationsProperties } from '../../../../test/jest/helpers';

import { Default } from './Default';

const onClick = jest.fn();

const renderDefaultItemTemplate = () => {
  const component = (
    <Default
      caption="ui-data-import.run"
      icon="test icon"
      onClick={onClick}
    />
  );

  return renderWithIntl(component, translationsProperties);
};

describe('Action menu Default Item Template', () => {
  afterEach(() => {
    onClick.mockClear();
  });

  it('should be rendered', () => {
    expect(renderDefaultItemTemplate()).toBeDefined();
  });

  describe('when button is clicked', () => {
    it('then `onClick` function should be called', () => {
      const { getByText } = renderDefaultItemTemplate();

      fireEvent.click(getByText('Run'));

      expect(onClick.mock.calls.length).toEqual(1);
    });
  });
});
