"use strict";

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

var _InteractionType = _interopRequireDefault(require("quiz-interactions/lib/records/InteractionType"));

var _Edit = _interopRequireDefault(require("quiz-interactions/lib/components/multiple_choice/Edit"));

var _reactTestbed = _interopRequireDefault(require("../../../../../../../tests/util/react-testbed"));

var _presenter = _interopRequireDefault(require("../presenter"));

var _withContext = _interopRequireDefault(require("../../../../../../../tests/util/withContext"));

var _Item = _interopRequireDefault(require("../../../../../records/Item"));

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

describe('Item Override', function () {
  var ItemWithContext = (0, _withContext.default)(_presenter.default);
  var type = new _InteractionType.default({
    name: 'Multiple Choice',
    slug: 'choice'
  });
  var item = new _Item.default({
    id: '333',
    title: 'Difficult Question',
    interactionData: {
      choices: [{
        id: 'id1',
        itemBody: 'George Washington',
        position: 1
      }, {
        id: 'id2',
        itemBody: 'Alexander Hamilton.',
        position: 2
      }]
    },
    itemBody: 'body',
    scoringData: {
      value: 'id1'
    }
  });
  var quizEntry = new _QuizEntry.default({
    id: '222'
  });
  sinon.stub(item, 'getInteractionType').returns(type);
  var changePropertiesStub = sinon.stub();
  var testbed = (0, _reactTestbed.default)(ItemWithContext, {
    changeQuizEntryProperties: changePropertiesStub,
    entry: item,
    guid: '333',
    quizEntry: quizEntry
  });
  it('renders interaction in override mode', function () {
    testbed.render();
    var interaction = testbed.findChildByType(_Edit.default);
    expect(interaction.props.overrideEditableForItem).to.be.true();
    expect(testbed.findChildrenBySelector('input[type="radio"][aria-disabled="true"]'), 'Expected choice buttons to be disabled').to.have.length(2);
  });
  it('passes the correct oneQuestionAtATime value to the interaction', function () {
    testbed.render({
      oneQuestionAtATime: true
    });
    var component = testbed.findChildByType(_Edit.default);
    expect(component.props.oneQuestionAtATime).to.be.true();
  });
});