"use strict";

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

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

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

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

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

describe('QuizEntryEditFooter', function () {
  var sandbox = sinon.createSandbox();
  var item = new _Item.default({
    id: '66'
  });
  var workingItem = new _Item.default({
    id: '66',
    properties: {
      varyPointsByAnswer: false
    }
  });
  sandbox.stub(item, 'getWorkingInstance').returns(workingItem);
  var quizItemEntry = new _QuizEntry.default({
    id: '55',
    entryType: 'Item',
    entryId: 66,
    pointsPossible: 12,
    position: 3
  });
  var quizBankEntry = new _QuizEntry.default({
    id: '56',
    entryType: 'BankEntry',
    entryId: 77,
    pointsPossible: 12,
    position: 3
  });
  var quizStimulusEntry = new _QuizEntry.default({
    id: '56',
    entryType: 'Stimulus',
    entryId: 88,
    pointsPossible: 12,
    position: 3
  });
  var workingQuizEntry = new _QuizEntry.default({
    id: '55',
    pointsPossible: 3999
  });
  sandbox.stub(workingQuizEntry, 'getItem').returns(item);
  var defaultProps = {
    entry: item,
    workingQuizEntry: workingQuizEntry
  };
  describe('mapStateToProps', function () {
    context('when quizEntry.isItem', function () {
      it('gets item from workingQuizEntry', function () {
        var mapped = (0, _index.mapStateToProps)({}, (0, _objectSpread2.default)({}, defaultProps, {
          quizEntry: quizItemEntry
        }));
        expect(mapped.workingEntry).to.equal(item);
      });
    });
    context('when quizEntry.isBankEntry', function () {
      it('gets item from workingQuizEntry', function () {
        var mapped = (0, _index.mapStateToProps)({}, (0, _objectSpread2.default)({}, defaultProps, {
          quizEntry: quizBankEntry
        }));
        expect(mapped.workingEntry).to.equal(item);
      });
    });
    context('when quizEntry is not an item or bank entry', function () {
      it('gets working instance from entry', function () {
        var mapped = (0, _index.mapStateToProps)({}, (0, _objectSpread2.default)({}, defaultProps, {
          quizEntry: quizStimulusEntry
        }));
        expect(mapped.workingEntry).to.equal(workingItem);
      });
    });
  });
});