"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.fcFqb_bGBk{border-bottom:".concat(theme.rootBorderWidth || 'inherit', " solid ").concat(theme.rootBorderColor || 'inherit', ";overflow:hidden}\n\n.fcFqb_pJNU{border:").concat(theme.instructionsBorderWidth || 'inherit', " solid ").concat(theme.instructionsBorderColor || 'inherit', ";padding:").concat(theme.instructionsPaddingTopBottom || 'inherit', " ").concat(theme.instructionsPaddingLeftRight || 'inherit', "}\n\n.fcFqb_dEpm{font-weight:").concat(theme.instructionsHeaderFontWeight || 'inherit', ";padding-bottom:").concat(theme.instructionsHeaderPadding || 'inherit', "}\n\n.fcFqb_pypk{background-color:").concat(theme.infoBackgroundColor || 'inherit', ";height:100%;overflow:scroll;padding:").concat(theme.infoPaddingTopBottom || 'inherit', " ").concat(theme.infoPaddingLeftRight || 'inherit', "}\n\n.fcFqb_fsuY{padding-bottom:").concat(theme.headerPaddingBottom || 'inherit', ";padding-top:").concat(theme.headerPaddingTop || 'inherit', "}\n\n.fcFqb_nvdO{font-size:").concat(theme.titleFontSize || 'inherit', ";font-weight:").concat(theme.titleFontWeight || 'inherit', "}\n\n.fcFqb_JelF{padding:").concat(theme.itemsPadding || 'inherit', ";width:50%}\n\n.fcFqb_boAJ{flex:1 1 auto}\n\n.fcFqb_bbyJ{display:flex;flex-direction:row}\n\n.fcFqb_eNQJ{width:50%}\n\n@media screen and (--phoneBreakPoint){.fcFqb_bbyJ{flex-direction:column}.fcFqb_JelF,.fcFqb_eNQJ{width:100%}.fcFqb_pJNU{padding:").concat(theme.phoneInstructionsPaddingTopBottom || 'inherit', " ").concat(theme.phoneInstructionsPaddingLeftRight || 'inherit', "}.fcFqb_pypk{padding:").concat(theme.phoneInfoPadding || 'inherit', "}.fcFqb_eGWt{border-bottom:").concat(theme.phoneConnectingLinesBorderWidth || 'inherit', " dotted;border-color:").concat(theme.phoneConnectingLinesBorderColor || 'inherit', ";border-left:").concat(theme.phoneConnectingLinesBorderWidth || 'inherit', " dotted;flex:0 0 1rem;height:2rem;margin-right:").concat(theme.phoneConnectingLinesMargin || 'inherit', ";margin-top:").concat(theme.phoneConnectingLinesMargin || 'inherit', ";width:1.5rem}}");
  },
  'root': 'fcFqb_bGBk',
  'instructions': 'fcFqb_pJNU',
  'instructionsHeader': 'fcFqb_dEpm',
  'info': 'fcFqb_pypk',
  'header': 'fcFqb_fsuY',
  'title': 'fcFqb_nvdO',
  'items': 'fcFqb_JelF',
  'stimulusItem': 'fcFqb_boAJ',
  'stimulusGroup': 'fcFqb_bbyJ',
  'stimulusInfo': 'fcFqb_eNQJ',
  'connectingLines': 'fcFqb_eGWt'
};
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();
  });
});