"use strict";

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

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

var _immutable = require("immutable");

var _Stimulus = _interopRequireDefault(require("../../../../../records/Stimulus"));

var _index = _interopRequireDefault(require("../index"));

var _QuizEntry = _interopRequireDefault(require("../../../../../records/QuizEntry"));

var styles = {
  componentId: 'ceqOh',
  template: function template(theme) {
    return "\n\n.ceqOh_dRGY{padding-bottom:".concat(theme.stimulusPadding || 'inherit', ";padding-top:").concat(theme.stimulusPadding || 'inherit', "}\n\n.ceqOh_fsuY{align-items:center;display:flex;height:1rem;justify-content:space-between;padding-left:").concat(theme.headerPadding || 'inherit', ";padding-right:").concat(theme.headerPadding || 'inherit', "}\n\n.ceqOh_cKlw{display:flex;overflow:hidden}\n\n.ceqOh_ffXB{color:").concat(theme.stimulusLabelColor || 'inherit', ";font-size:").concat(theme.stimulusLabelFontSize || 'inherit', ";margin:0 ").concat(theme.stimulusLabelMargin || 'inherit', ";overflow:hidden;text-overflow:ellipsis}\n\n.ceqOh_dMwa{height:100%;padding:").concat(theme.stimulusContentPaddingTop || 'inherit', " ").concat(theme.stimulusContentPaddingLeftRight || 'inherit', " ").concat(theme.stimulusContentPaddingBottom || 'inherit', "}");
  },
  'stimulus': 'ceqOh_dRGY',
  'header': 'ceqOh_fsuY',
  'leftHeader': 'ceqOh_cKlw',
  'stimulusLabel': 'ceqOh_ffXB',
  'stimulusContent': 'ceqOh_dMwa'
};
describe('StimulusShow', function () {
  var editingStub = sinon.stub();
  var openDeleteStimulusModalStub = sinon.stub();
  var stimulus = new _Stimulus.default({
    id: 55,
    title: 'Title',
    instructions: 'Instructions',
    body: '<em>Body</em>',
    sourceUrl: 'Source URL'
  });
  var defaultProps = {
    displayPosition: 1,
    openDeleteStimulusModal: openDeleteStimulusModalStub,
    stimulus: stimulus,
    switchOnEditing: editingStub,
    connectDragSource: function connectDragSource(C) {
      return C;
    },
    quizEntries: (0, _immutable.fromJS)([new _QuizEntry.default(), new _QuizEntry.default()]),
    quizEntry: new _QuizEntry.default()
  };
  var testbed = createTestbed(withContext(_index.default), defaultProps);
  afterEach(function () {
    editingStub.resetHistory();
    openDeleteStimulusModalStub.resetHistory();
  });
  it('switches to editing mode on click', function () {
    testbed.render();
    var button = testbed.findChildrenByClass(styles.stimulusContent)[0];

    _testUtils.default.Simulate.click(button);

    expect(editingStub.called).to.be.true();
  });
  it('opens the delete stimulus modal on click', function () {
    testbed.render();
    var button = testbed.findChildrenByTagNameAndAttribute('div', 'role', 'button')[2];

    _testUtils.default.Simulate.click(button);

    expect(openDeleteStimulusModalStub.called).to.be.true();
  });
  describe('a11y tests', function () {
    it('should meet a11y standards', function (done) {
      testbed.render();
      testbed.checkA11yStandards(done, {
        ignores: ['label', 'label-title-only']
      });
    });
  });
});