"use strict";

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

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

var _multiple_choice = _interopRequireDefault(require("quiz-interactions/lib/records/interactions/multiple_choice"));

var _immutable = require("immutable");

var _BankEntry = _interopRequireDefault(require("../../../../../../common/records/BankEntry"));

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

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

var _featureCheck = require("../../../../../../common/util/featureCheck");

var _dndTestUtils = require("../../../../../../../tests/util/dndTestUtils");

describe('connected QuizEntry', function () {
  var intType = new _multiple_choice.default({});
  var item = new _Item.default({
    id: '100',
    itemBody: '<div>first</div>&amp;<div>second</div>'
  });
  var bankEntry = new _BankEntry.default({
    id: '11',
    'entryType': 'Item'
  });
  var quizEntry = new _QuizEntry.default({
    id: '99',
    position: 1,
    entryType: 'BankEntry'
  });
  sinon.stub(quizEntry, 'getEntry').returns(bankEntry);
  sinon.stub(quizEntry, 'getWorkingInstance').returns(quizEntry);
  sinon.stub(quizEntry, 'getItem').returns(item);
  sinon.stub(bankEntry, 'getEntry').returns(item);
  sinon.stub(item, 'getInteractionType').returns(intType);
  var connectedTestbed = createTestbed(withContext((0, _dndTestUtils.wrapInDragAndDropTestContext)(_index.default), {
    tagAssociations: {
      Item: {
        100: (0, _immutable.fromJS)([{
          id: 1,
          tag_value: 'waldo'
        }])
      }
    }
  }), {
    connectDropTarget: function connectDropTarget(Component) {
      return Component;
    },
    // inserted by React DnD
    quizEntry: quizEntry,
    quizEntries: {}
  });
  describe('without tagging', function () {
    it('does not render tag', function () {
      connectedTestbed.render();
      expect(connectedTestbed.getText()).not.to.include('waldo');
    });
  });
  describe('with tagging', function () {
    (0, _featureCheck.withTestFeatures)(['item_bank_tagging']);
    it('renders tag', function () {
      connectedTestbed.render();
      expect(connectedTestbed.getText()).to.include('waldo');
    });
  });
});