"use strict";

var _testUtilities = require("testUtilities");
var _index = _interopRequireDefault(require("./index"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var addEventListener = document.addEventListener;
afterEach(function () {
  return document.addEventListener = addEventListener;
});
it("renders", function () {
  document.addEventListener = jest.fn();
  var _renderHookWithProvid = (0, _testUtilities.renderHookWithProviders)(function () {
      return (0, _index["default"])();
    }),
    result = _renderHookWithProvid.result;
  _testUtilities.fireEvent.keyDown(document, {
    keyCode: 27
  });
  expect(result.error).toBeUndefined();
  expect(document.addEventListener).toHaveBeenCalledTimes(0);
});
it("triggers on enter keystroke", function () {
  var callback = jest.fn();
  (0, _testUtilities.renderHookWithProviders)(function () {
    return (0, _index["default"])(callback);
  });
  _testUtilities.fireEvent.keyDown(document, {
    keyCode: 27
  });
  expect(callback).toHaveBeenCalledTimes(1);
});
it("does not trigger on non enter keystroke", function () {
  var callback = jest.fn();
  (0, _testUtilities.renderHookWithProviders)(function () {
    return (0, _index["default"])(callback);
  });
  _testUtilities.fireEvent.keyDown(document, {
    keyCode: 26
  });
  expect(callback).toHaveBeenCalledTimes(0);
});