import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
// react-addons-shallow-compare and react-addons-test-utils are required for enzyme
// jshint esversion: 6
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import ReactWrapper from "enzyme/build/ReactWrapper";
import ShallowWrapper from "enzyme/build/ShallowWrapper";
import ReactDOMServer from 'react-dom/server';
import cheerio from "cheerio";
configure({
  adapter: new Adapter()
});
var TEST_ID_DELIMITER = '.';
var TEST_ID_ATTRIBUTE = 'data-test-automation-id';

var ReactWrapperWMU =
/*#__PURE__*/
function (_ReactWrapper) {
  _inheritsLoose(ReactWrapperWMU, _ReactWrapper);

  function ReactWrapperWMU() {
    return _ReactWrapper.apply(this, arguments) || this;
  }

  var _proto = ReactWrapperWMU.prototype;

  _proto.findByTestAutomation = function findByTestAutomation(path) {
    var w = this;
    path = path.split(TEST_ID_DELIMITER);

    while (path.length && w) {
      var _w$find;

      w = w.find((_w$find = {}, _w$find[TEST_ID_ATTRIBUTE] = path.shift(), _w$find));
    }

    return w;
  };

  return ReactWrapperWMU;
}(ReactWrapper);

export function render(node) {
  var html = ReactDOMServer.renderToStaticMarkup(node);
  return cheerio.load(html).root();
}
export function shallow(node, options) {
  return new ShallowWrapper(node, null, options);
}
export function mount(node, options) {
  return new ReactWrapperWMU(node, null, options);
}