"use strict";

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

var _immutable = require("immutable");

var _SessionItem = _interopRequireDefault(require("../../../../../records/SessionItem"));

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

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

var styles = {
  componentId: 'fcFqb',
  template: function template(theme) {
    return "\n\n.ResultStimulus__styles__root {\n  border-bottom: ".concat(theme.rootBorderWidth || 'inherit', " solid ").concat(theme.rootBorderColor || 'inherit', ";\n  overflow: hidden;\n}\n\n.ResultStimulus__styles__instructions {\n  padding: ").concat(theme.instructionsPaddingTopBottom || 'inherit', " ").concat(theme.instructionsPaddingLeftRight || 'inherit', ";\n  border: ").concat(theme.instructionsBorderWidth || 'inherit', " solid ").concat(theme.instructionsBorderColor || 'inherit', ";\n}\n\n.ResultStimulus__styles__instructionsHeader {\n  padding-bottom: ").concat(theme.instructionsHeaderPadding || 'inherit', ";\n  font-weight: ").concat(theme.instructionsHeaderFontWeight || 'inherit', ";\n}\n\n.ResultStimulus__styles__info {\n  padding: ").concat(theme.infoPaddingTopBottom || 'inherit', " ").concat(theme.infoPaddingLeftRight || 'inherit', ";\n  background-color: ").concat(theme.infoBackgroundColor || 'inherit', ";\n  height: 100%;\n  overflow: scroll;\n}\n\n.ResultStimulus__styles__header {\n  padding-top: ").concat(theme.headerPaddingTop || 'inherit', ";\n  padding-bottom: ").concat(theme.headerPaddingBottom || 'inherit', ";\n}\n\n.ResultStimulus__styles__title {\n  font-size: ").concat(theme.titleFontSize || 'inherit', ";\n  font-weight: ").concat(theme.titleFontWeight || 'inherit', ";\n}\n\n.ResultStimulus__styles__items {\n  padding: ").concat(theme.itemsPadding || 'inherit', ";\n  width: 50%;\n}\n\n.ResultStimulus__styles__stimulusItem {\n  flex: 1 1 auto;\n}\n\n.ResultStimulus__styles__stimulusGroup {\n  display: flex;\n  flex-direction: row;\n}\n\n.ResultStimulus__styles__stimulusInfo {\n  width: 50%;\n}\n\n@media screen and (--phoneBreakPoint) {\n  .ResultStimulus__styles__stimulusGroup {\n    flex-direction: column;\n  }\n\n  .ResultStimulus__styles__stimulusInfo {\n    width: 100%;\n  }\n\n  .ResultStimulus__styles__items {\n    width: 100%;\n  }\n\n  .ResultStimulus__styles__instructions {\n    padding: ").concat(theme.phoneInstructionsPaddingTopBottom || 'inherit', " ").concat(theme.phoneInstructionsPaddingLeftRight || 'inherit', ";\n  }\n\n  .ResultStimulus__styles__info {\n    padding: ").concat(theme.phoneInfoPadding || 'inherit', ";\n  }\n\n  .ResultStimulus__styles__connectingLines {\n    flex: 0 0 1rem;\n\n    border-left: ").concat(theme.phoneConnectingLinesBorderWidth || 'inherit', " dotted;\n    border-bottom: ").concat(theme.phoneConnectingLinesBorderWidth || 'inherit', " dotted;\n    border-color: ").concat(theme.phoneConnectingLinesBorderColor || 'inherit', ";\n\n    margin-top: ").concat(theme.phoneConnectingLinesMargin || 'inherit', ";\n    margin-right: ").concat(theme.phoneConnectingLinesMargin || 'inherit', ";\n    height: 2rem;\n    width: 1.5rem;\n  }\n}\n");
  },
  'root': 'ResultStimulus__styles__root',
  'instructions': 'ResultStimulus__styles__instructions',
  'instructionsHeader': 'ResultStimulus__styles__instructionsHeader',
  'info': 'ResultStimulus__styles__info',
  'header': 'ResultStimulus__styles__header',
  'title': 'ResultStimulus__styles__title',
  'items': 'ResultStimulus__styles__items',
  'stimulusItem': 'ResultStimulus__styles__stimulusItem',
  'stimulusGroup': 'ResultStimulus__styles__stimulusGroup',
  'stimulusInfo': 'ResultStimulus__styles__stimulusInfo',
  'connectingLines': 'ResultStimulus__styles__connectingLines'
};
describe('ResultStimulus', function () {
  var renderItemStub = sinon.stub();
  var emptyStimulus = new _Stimulus.default();
  var stimulus = new _Stimulus.default({
    sourceUrl: 'google.com',
    instructions: 'my awesome instructions'
  });
  var sessionItem = new _SessionItem.default();
  sinon.stub(sessionItem, 'getNestedEntries').returns((0, _immutable.Map)({
    1: new _SessionItem.default({
      position: 1
    }),
    2: new _SessionItem.default({
      position: 2
    }),
    3: new _SessionItem.default({
      position: 3
    })
  }));
  var defaultProps = {
    renderItem: renderItemStub,
    stimulus: stimulus,
    sessionItem: sessionItem
  };
  var testbed = createTestbed(_index.default, defaultProps);
  shouldRenderComponent(testbed, {}, _index.default);
  afterEach(function () {
    renderItemStub.resetHistory();
  });
  it('should render the correct number of items', function () {
    testbed.render();
    var items = testbed.findChildrenByClass(styles.stimulusItem);
    expect(items.length).to.be.equal(3);
  });
  it('should call the renderItem prop when rendering', function () {
    testbed.render();
    expect(renderItemStub).to.be.called();
  });
  it('should render instructions if present', function () {
    testbed.render();
    var instructions = testbed.findChildrenByClass(styles.instructions)[0];
    expect(instructions).to.not.be.undefined();
  });
  it('should not render instructions if not present', function () {
    testbed.render({
      stimulus: emptyStimulus
    });
    var instructions = testbed.findChildrenByType(styles.instructions)[0];
    expect(instructions).to.be.undefined();
  });
});