"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.cwwgG_kQJA{border-bottom:".concat(theme.bottomBorderWidth || 'inherit', " solid ").concat(theme.bottomBorderColor || 'inherit', ";border-right:").concat(theme.hoverBorderWidth || 'inherit', " solid ").concat(theme.borderColor || 'inherit', "}\n\n.cwwgG_kQJA:hover{border-right:").concat(theme.hoverBorderWidth || 'inherit', " solid ").concat(theme.hoverBorderColor || 'inherit', "}\n\n.cwwgG_cdGL{color:").concat(theme.infoHeaderColor || 'inherit', ";display:flex;font-size:").concat(theme.infoHeaderFontSize || 'inherit', "}\n\n.cwwgG_ecuB{width:60%}\n\n.cwwgG_echV{width:40%}\n\n.cwwgG_doeu{font-size:").concat(theme.numberFontSize || 'inherit', ";font-weight:").concat(theme.numberFontWeight || 'inherit', "}\n\n.cwwgG_doeu,.cwwgG_esVF{color:").concat(theme.darkTextColor || 'inherit', "}\n\n.cwwgG_esVF{font-size:").concat(theme.itemBodyFontSize || 'inherit', ";margin-top:").concat(theme.itemBodyMarginTop || 'inherit', ";overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n\n.cwwgG_fBqo{cursor:pointer;position:relative}\n\n.cwwgG_eQGE{margin:0 ").concat(theme.sidebarClosedMargin || 'inherit', ";padding:").concat(theme.sidebarClosedPadding || 'inherit', " 0;text-align:center}\n\n[dir=ltr] .cwwgG_eQGE,[dir=rtl] .cwwgG_eQGE{text-align:center}\n\n.cwwgG_csre{display:flex;justify-content:flex-end}\n\n.cwwgG_cRFW{border-bottom:none}\n\n.cwwgG_eNNp{padding:").concat(theme.sidebarIsOpenPadding || 'inherit', "}\n\n.cwwgG_eNNp.cwwgG_cRFW{margin-left:10%}\n\n.cwwgG_eNNp .cwwgG_fBqo{font-size:").concat(theme.sidebarIsOpenMainTextFontSize || 'inherit', ";margin-top:").concat(theme.mainTextPaddingTop || 'inherit', "}");
  },
  'sidebarItem': 'cwwgG_kQJA',
  'infoHeader': 'cwwgG_cdGL',
  'interactionType': 'cwwgG_ecuB',
  'pointsPossible': 'cwwgG_echV',
  'displayNumber': 'cwwgG_doeu',
  'itemBody': 'cwwgG_esVF',
  'mainText': 'cwwgG_fBqo',
  'sidebarClosed': 'cwwgG_eQGE',
  'pinWrapper': 'cwwgG_csre',
  'inStimulus': 'cwwgG_cRFW',
  'sidebarIsOpen': 'cwwgG_eNNp'
};
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);
    });
  });
});