import React from 'react';

import 'jest-dom/extend-expect';
import 'react-testing-library/cleanup-after-each';

import { toBeInTheDocument, toHaveClass, toBeVisible } from 'jest-dom';
expect.extend({ toBeInTheDocument, toHaveClass, toBeVisible });

jest.mock('@fullpage/react-fullpage', () => {
  const React = require('react');
  const ReactDOM = require('react-dom');

  let ActiveSection = {};
  let AllChildren = [];

  return class MyFullPageMock extends React.Component {
    static Wrapper = ({ children }) => {

      AllChildren = children;
      ActiveSection = children[0];

      return <div>{children}</div>;
    }

    constructor(props) {
      super(props);
    }

    render() {
      return this.props.render({ fullpageApi: {
        moveSectionUp: () => {
          ActiveSection = AllChildren[0];
        },
        moveSectionDown: () => {
          ActiveSection = AllChildren[1];
        },
        getActiveSection: () => {
          return { item: <ActiveSection /> };
        }
      } });
    }
  };
});

window.matchMedia = window.matchMedia ||
  function () {
    return {
      matches: false,
      addListener () {},
      removeListener () {}
    };
  };
