import React from 'react';
import { mount } from 'enzyme';
import { MemoryRouter } from 'react-router-dom';

import {
  IVulnerabilityConfigInputProps,
  Vulnerability,
} from './Vulnerability';

const genVulnerabilitytWrapper = (propsOverrides: Partial<IVulnerabilityConfigInputProps> = {}): ReturnType<typeof mount> => {
    const props: IVulnerabilityConfigInputProps = {
        system: {
            uid: 'SOME-UID',
            filename: 'test.cfr',
            configs: [],
            conftree: {
                constraints: [],
                features: {},
                roots: [],
                version: {
                    base: 1,
                }
            },
            configuredConftree: {
              constraints: [],
              features: {},
              roots: [],
              version: {
                  base: 1,
              }
          },
            createdAt: 'SOME DATE',
            featureCount: 0,
            lastUpdate: 'SOME OTHER DATE',
            selectionUndos: [],
        },
        isLoading: false,
        fetchSystemByVulnConfig: jest.fn(),
        submitVulnerabilityClass: jest.fn(),
        selectFeature: jest.fn(),
        selectFeatureUndo: jest.fn(),
        selectFeatureRedo: jest.fn(),
        submitValidateConfiguration: jest.fn(),
        ...propsOverrides,
    };

    return mount(
      <MemoryRouter initialEntries={['/vuln-configuration/create']}>
        <Vulnerability {...props} />
      </MemoryRouter>
    );
};

describe('Vulnerability', () => {

  it('renders without crashing', () => {
    const wrapper = genVulnerabilitytWrapper();

    expect(wrapper.html()).toBeTruthy();
  });
});
