"use strict";

var _testUtilities = require("testUtilities");
var _index = _interopRequireDefault(require("./index"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var injectElements = function injectElements() {
  var div1 = document.createElement("div");
  var div2 = document.createElement("div");
  div1.appendChild(div2);
  document.body.appendChild(div1);
  var div3 = document.createElement("div");
  document.body.appendChild(div3);
  return {
    div1: div1,
    div2: div2,
    div3: div3
  };
};
it("renders", function () {
  var _renderHookWithProvid = (0, _testUtilities.renderHookWithProviders)(function () {
      return (0, _index["default"])();
    }),
    result = _renderHookWithProvid.result;
  expect(result.error).toBeUndefined();
});
it("trigger on outside click", function () {
  var _injectElements = injectElements(),
    div2 = _injectElements.div2,
    div3 = _injectElements.div3;
  var onClickOutside = jest.fn();
  (0, _testUtilities.renderHookWithProviders)(function () {
    return (0, _index["default"])({
      current: div2
    }, onClickOutside);
  });
  _testUtilities.fireEvent.mouseDown(div3);
  expect(onClickOutside).toBeCalledTimes(1);
});
it("does not trigger on inner click", function () {
  var _injectElements2 = injectElements(),
    div1 = _injectElements2.div1,
    div2 = _injectElements2.div2;
  var onClickOutside = jest.fn();
  (0, _testUtilities.renderHookWithProviders)(function () {
    return (0, _index["default"])({
      current: div1
    }, onClickOutside);
  });
  _testUtilities.fireEvent.mouseDown(div2);
  expect(onClickOutside).toBeCalledTimes(0);
});
it("does not trigger on the same element", function () {
  var _injectElements3 = injectElements(),
    div1 = _injectElements3.div1;
  var onClickOutside = jest.fn();
  (0, _testUtilities.renderHookWithProviders)(function () {
    return (0, _index["default"])({
      current: div1
    }, onClickOutside);
  });
  _testUtilities.fireEvent.mouseDown(div1);
  expect(onClickOutside).toBeCalledTimes(0);
});