"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _chai = require("chai");

var _keyboardClickable = _interopRequireDefault(require("../keyboardClickable"));

describe('keyboardClickable', function () {
  context('when given a spacebar key event', function () {
    it('fires a click event on target', function () {
      var spaceDownEvent = {
        keyCode: 13,
        target: {
          click: sinon.spy()
        },
        stopPropagation: sinon.spy(),
        preventDefault: sinon.spy()
      };
      (0, _keyboardClickable.default)(spaceDownEvent);
      (0, _chai.expect)(spaceDownEvent.target.click.callCount).to.eq(1);
      (0, _chai.expect)(spaceDownEvent.stopPropagation.callCount).to.eq(1);
      (0, _chai.expect)(spaceDownEvent.preventDefault.callCount).to.eq(1);
    });
  });
  context('when given a non spacebar or enter key event', function () {
    it('does not fire a click event on target', function () {
      var shiftDownEvent = {
        keyCode: 16,
        target: {
          click: sinon.spy()
        },
        stopPropagation: sinon.spy(),
        preventDefault: sinon.spy()
      };
      (0, _keyboardClickable.default)(shiftDownEvent);
      (0, _chai.expect)(shiftDownEvent.target.click.callCount).to.eq(0);
      (0, _chai.expect)(shiftDownEvent.stopPropagation.callCount).to.eq(0);
      (0, _chai.expect)(shiftDownEvent.preventDefault.callCount).to.eq(0);
    });
  });
});