import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import React from 'react';
import PublicEventPanel from '../../components/Logbook/PublicEventPanel';

const resources = require('./resources/PublicEventPanel.resource.js');

require('it-each')({ testPerIteration: true });

/* code executed before each test */
beforeEach(() => {
  Enzyme.configure({ adapter: new Adapter() });
});

describe.skip('PublicEventPanelIntegrationTests', () => {
  describe('Test callback triggering functions', () => {
    test('User clicks on the close button', () => {
      const input = resources.functionalProps;
      const mockedOnCloseButtonClicked = jest.fn();
      const wrapper = getMountedWrapper({
        event: input.event,
        onCloseButtonClicked: mockedOnCloseButtonClicked,
      });

      expect(mockedOnCloseButtonClicked).toHaveBeenCalledTimes(0);
      wrapper.find('EventFooter').find('Button').simulate('click');
      expect(mockedOnCloseButtonClicked).toHaveBeenCalledTimes(1);
    });
  });
});

function getMountedWrapper(propsObject) {
  return Enzyme.mount(
    <PublicEventPanel
      event={propsObject.event}
      onCloseButtonClicked={
        propsObject.onCloseButtonClicked
          ? propsObject.onCloseButtonClicked
          : () => null
      }
    />
  );
}
