"use strict";

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

var _react = _interopRequireDefault(require("react"));

var _enzyme = require("enzyme");

var _ = _interopRequireDefault(require("."));

describe('TutorialTile', function () {
  var node;
  var props;
  beforeEach(function () {
    props = {
      openTutorial: jest.fn(),
      tutorial: {
        backgroundColor: 'fff',
        description: 'test tutorial desc',
        title: 'test tutorial title',
        emoji: '🦉',
        _id: '123'
      }
    };
    node = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_["default"], props));
  });
  it('should display the TutorialTile component', function () {
    expect(node.find('.TutorialTile').hasClass('TutorialTile')).toBe(true);
  });
  it('should handle button click event', function () {
    node.simulate('click');
    expect(props.openTutorial).toHaveBeenCalledWith({
      tutorial: props.tutorial
    });
  });
  it('should handle keydown event', function () {
    node.simulate('keydown', {
      keyCode: 13,
      stopPropagation: jest.fn()
    });
    expect(props.openTutorial).toHaveBeenCalledWith({
      tutorial: props.tutorial
    });
  });
  describe('callout', function () {
    var calloutNode;
    var calloutProps;
    beforeEach(function () {
      calloutProps = {
        tutorial: {
          backgroundColor: 'fff',
          description: 'test tutorial desc',
          title: 'test tutorial title',
          emoji: '🦉',
          _id: '123'
        },
        status: 'New'
      };
      calloutNode = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_["default"], calloutProps, "Only for admins!"));
    });
    it('should display a callout of given children', function () {
      var n = !!calloutNode.find('.TutorialTile').find('.TutorialTile-Notification');
      expect(n).toBe(true);
    });
    it('should dismiss callout display onclick', function () {
      var button = calloutNode.find('.TutorialTile').find('button');
      button.simulate('click');
      expect(calloutNode.find('.TutorialTile').hasClass('TutorialTile-Notification')).toBe(false);
    });
    it('should not open tutorial on dismiss click or enter', function () {
      var div = calloutNode.find('.TutorialTile').find('.TutorialTile-Notification');
      var spy = jest.fn();
      div.simulate('keydown', {
        keyCode: 13,
        stopPropagation: spy
      });
      expect(spy).toHaveBeenCalledTimes(1);
    });
  });
});