import { GlLink } from '@gitlab/ui';
import VulnerabilityReportHeader from 'ee/security_dashboard/components/shared/vulnerability_report/vulnerability_report_header.vue';
import { mountExtended } from 'helpers/vue_test_utils_helper';
import CsvExportButton from 'ee/security_dashboard/components/shared/csv_export_button.vue';

describe('Vulnerability report header component', () => {
  let wrapper;

  const createWrapper = ({ dashboardDocumentation } = {}) => {
    wrapper = mountExtended(VulnerabilityReportHeader, {
      provide: { dashboardDocumentation },
      stubs: { CsvExportButton: true },
    });
  };

  afterEach(() => {
    wrapper.destroy();
  });

  it('shows the CSV export button', () => {
    createWrapper();

    expect(wrapper.findComponent(CsvExportButton).exists()).toBe(true);
  });

  it('shows the correct link for the documentation', () => {
    const dashboardDocumentation = 'http://some/link';
    createWrapper({ dashboardDocumentation });

    expect(wrapper.findComponent(GlLink).attributes('href')).toBe(dashboardDocumentation);
  });
});
