"use strict";

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

var _testUtils = _interopRequireDefault(require("react-dom/test-utils"));

var _Button = _interopRequireDefault(require("@instructure/ui-buttons/lib/components/Button"));

var _presenter = _interopRequireDefault(require("../presenter"));

var styles = {
  componentId: 'cwwgG',
  template: function template(theme) {
    return "\n\n.SidebarItem__styles__sidebarItem {\n  border-right: ".concat(theme.hoverBorderWidth || 'inherit', " solid ").concat(theme.borderColor || 'inherit', ";\n  border-bottom: ").concat(theme.bottomBorderWidth || 'inherit', " solid ").concat(theme.bottomBorderColor || 'inherit', ";\n}\n\n.SidebarItem__styles__sidebarItem:hover {\n  border-right: ").concat(theme.hoverBorderWidth || 'inherit', " solid ").concat(theme.hoverBorderColor || 'inherit', ";\n}\n\n.SidebarItem__styles__infoHeader {\n  font-size: ").concat(theme.infoHeaderFontSize || 'inherit', ";\n  display: flex;\n  color: ").concat(theme.infoHeaderColor || 'inherit', ";\n}\n\n.SidebarItem__styles__interactionType {\n  width: 60%;\n}\n\n.SidebarItem__styles__pointsPossible {\n  width: 40%;\n}\n\n.SidebarItem__styles__displayNumber {\n  color: ").concat(theme.darkTextColor || 'inherit', ";\n  font-size: ").concat(theme.numberFontSize || 'inherit', ";\n  font-weight: ").concat(theme.numberFontWeight || 'inherit', ";\n}\n\n.SidebarItem__styles__itemBody {\n  font-size: ").concat(theme.itemBodyFontSize || 'inherit', ";\n  color: ").concat(theme.darkTextColor || 'inherit', ";\n  white-space: nowrap;\n  text-overflow: ellipsis;\n  overflow: hidden;\n  margin-top: ").concat(theme.itemBodyMarginTop || 'inherit', ";\n}\n\n.SidebarItem__styles__mainText {\n  position: relative;\n  cursor: pointer;\n}\n\n.SidebarItem__styles__sidebarClosed {\n  padding: ").concat(theme.sidebarClosedPadding || 'inherit', " 0;\n  margin: 0 ").concat(theme.sidebarClosedMargin || 'inherit', ";\n  text-align: center;\n}\n\n[dir=\"ltr\"] .SidebarItem__styles__sidebarClosed {\n  text-align: center;\n}\n\n[dir=\"rtl\"] .SidebarItem__styles__sidebarClosed {\n  text-align: center;\n}\n\n.SidebarItem__styles__pinWrapper {\n  display: flex;\n  justify-content: flex-end;\n}\n\n.SidebarItem__styles__inStimulus {\n  border-bottom: none;\n}\n\n\n\n\n\n.SidebarItem__styles__sidebarIsOpen {\n  padding: ").concat(theme.sidebarIsOpenPadding || 'inherit', ";\n}\n\n.SidebarItem__styles__sidebarIsOpen.SidebarItem__styles__inStimulus {\n    margin-left: 10%;\n  }\n\n.SidebarItem__styles__sidebarIsOpen .SidebarItem__styles__mainText {\n    font-size: ").concat(theme.sidebarIsOpenMainTextFontSize || 'inherit', ";\n    margin-top: ").concat(theme.mainTextPaddingTop || 'inherit', ";\n  }\n");
  },
  'sidebarItem': 'SidebarItem__styles__sidebarItem',
  'infoHeader': 'SidebarItem__styles__infoHeader',
  'interactionType': 'SidebarItem__styles__interactionType',
  'pointsPossible': 'SidebarItem__styles__pointsPossible',
  'displayNumber': 'SidebarItem__styles__displayNumber',
  'itemBody': 'SidebarItem__styles__itemBody',
  'mainText': 'SidebarItem__styles__mainText',
  'sidebarClosed': 'SidebarItem__styles__sidebarClosed',
  'pinWrapper': 'SidebarItem__styles__pinWrapper',
  'inStimulus': 'SidebarItem__styles__inStimulus',
  'sidebarIsOpen': 'SidebarItem__styles__sidebarIsOpen'
};
describe('Common SidebarItem Presenter', function () {
  var scrollSpy = sinon.spy();
  var props = {
    itemId: '1',
    itemBody: '<div>Hello</div>',
    itemName: 'Multiple Choice',
    position: '1',
    pointsPossible: 2,
    sidebarOpen: true,
    // from connect
    scrollToItem: scrollSpy
  };
  var testbed = createTestbed(_presenter.default, props);
  shouldRenderComponent(testbed, {}, _presenter.default);
  it('should call scrollToItem with the item id', function () {
    testbed.render();
    var sidebarItem = testbed.findChildByType(_Button.default);
    testbed.click(sidebarItem);
    expect(scrollSpy.called).to.be.true();
  });
  it('should call scrollToItem with the item id on space or enter', function () {
    testbed.render();
    var sidebarItem = testbed.findChildrenByClass(styles.mainText)[0];

    _testUtils.default.Simulate.keyDown(sidebarItem, {
      keyCode: 13
    });

    expect(scrollSpy.called).to.be.true();
  });
  it('should include a friendly interaction type', function () {
    testbed.render();
    var interactionType = testbed.findChildrenByClass(styles.interactionType)[0];
    expect(interactionType.innerHTML).to.include('Multiple Choice');
  });
  it('should include possible points', function () {
    testbed.render();
    var pointsPossible = testbed.findChildrenByClass(styles.pointsPossible)[0];
    expect(pointsPossible.innerHTML).to.include('2 points');
  });
  it('should include a question index', function () {
    testbed.render({
      displayPosition: '42'
    });
    var positionNode = testbed.findChildrenByClass(styles.sidebarIsOpen)[0];
    expect(positionNode.innerHTML).to.include('42');
  });
  describe('a11y tests', function () {
    it('should meet a11y standards', function (done) {
      testbed.render();
      testbed.checkA11yStandards(done);
    });
  });
});