"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.quiz-core__SidebarItem--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.quiz-core__SidebarItem--sidebarItem:hover {\n  border-right: ").concat(theme.hoverBorderWidth || 'inherit', " solid ").concat(theme.hoverBorderColor || 'inherit', ";\n}\n\n.quiz-core__SidebarItem--infoHeader {\n  font-size: ").concat(theme.infoHeaderFontSize || 'inherit', ";\n  display: flex;\n  color: ").concat(theme.infoHeaderColor || 'inherit', ";\n}\n\n.quiz-core__SidebarItem--interactionType {\n  width: 60%;\n}\n\n.quiz-core__SidebarItem--pointsPossible {\n  width: 40%;\n}\n\n.quiz-core__SidebarItem--displayNumber {\n  color: ").concat(theme.darkTextColor || 'inherit', ";\n  font-size: ").concat(theme.numberFontSize || 'inherit', ";\n  font-weight: ").concat(theme.numberFontWeight || 'inherit', ";\n}\n\n.quiz-core__SidebarItem--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.quiz-core__SidebarItem--mainText {\n  position: relative;\n  cursor: pointer;\n}\n\n.quiz-core__SidebarItem--sidebarClosed {\n  padding: ").concat(theme.sidebarClosedPadding || 'inherit', " 0;\n  margin: 0 ").concat(theme.sidebarClosedMargin || 'inherit', ";\n  text-align: center;\n}\n\n[dir=\"ltr\"] .quiz-core__SidebarItem--sidebarClosed {\n  text-align: center;\n}\n\n[dir=\"rtl\"] .quiz-core__SidebarItem--sidebarClosed {\n  text-align: center;\n}\n\n.quiz-core__SidebarItem--pinWrapper {\n  display: flex;\n  justify-content: flex-end;\n}\n\n.quiz-core__SidebarItem--inStimulus {\n  border-bottom: none;\n}\n\n\n\n\n\n.quiz-core__SidebarItem--sidebarIsOpen {\n  padding: ").concat(theme.sidebarIsOpenPadding || 'inherit', ";\n}\n\n.quiz-core__SidebarItem--sidebarIsOpen.quiz-core__SidebarItem--inStimulus {\n    margin-left: 10%;\n  }\n\n.quiz-core__SidebarItem--sidebarIsOpen .quiz-core__SidebarItem--mainText {\n    font-size: ").concat(theme.sidebarIsOpenMainTextFontSize || 'inherit', ";\n    margin-top: ").concat(theme.mainTextPaddingTop || 'inherit', ";\n  }\n");
  },
  'sidebarItem': 'quiz-core__SidebarItem--sidebarItem',
  'infoHeader': 'quiz-core__SidebarItem--infoHeader',
  'interactionType': 'quiz-core__SidebarItem--interactionType',
  'pointsPossible': 'quiz-core__SidebarItem--pointsPossible',
  'displayNumber': 'quiz-core__SidebarItem--displayNumber',
  'itemBody': 'quiz-core__SidebarItem--itemBody',
  'mainText': 'quiz-core__SidebarItem--mainText',
  'sidebarClosed': 'quiz-core__SidebarItem--sidebarClosed',
  'pinWrapper': 'quiz-core__SidebarItem--pinWrapper',
  'inStimulus': 'quiz-core__SidebarItem--inStimulus',
  'sidebarIsOpen': 'quiz-core__SidebarItem--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);
    });
  });
});