"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.StimulusShow__styles__stimulus {\n  padding-top: ".concat(theme.stimulusPadding || 'inherit', ";\n  padding-bottom: ").concat(theme.stimulusPadding || 'inherit', ";\n}\n\n.StimulusShow__styles__header {\n  height: 1rem;\n  padding-left: ").concat(theme.headerPadding || 'inherit', ";\n  padding-right: ").concat(theme.headerPadding || 'inherit', ";\n\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n}\n\n.StimulusShow__styles__leftHeader {\n  display: flex;\n  overflow: hidden;\n}\n\n.StimulusShow__styles__stimulusLabel {\n  color: ").concat(theme.stimulusLabelColor || 'inherit', ";\n  font-size: ").concat(theme.stimulusLabelFontSize || 'inherit', ";\n  margin: 0 ").concat(theme.stimulusLabelMargin || 'inherit', ";\n  overflow: hidden;\n  text-overflow: ellipsis;\n}\n\n.StimulusShow__styles__stimulusContent {\n  height: 100%;\n  padding: ").concat(theme.stimulusContentPaddingTop || 'inherit', " ").concat(theme.stimulusContentPaddingLeftRight || 'inherit', " ").concat(theme.stimulusContentPaddingBottom || 'inherit', ";\n}\n");
  },
  'stimulus': 'StimulusShow__styles__stimulus',
  'header': 'StimulusShow__styles__header',
  'leftHeader': 'StimulusShow__styles__leftHeader',
  'stimulusLabel': 'StimulusShow__styles__stimulusLabel',
  'stimulusContent': 'StimulusShow__styles__stimulusContent'
};
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']
      });
    });
  });
});