"use strict";

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

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

var _immutable = require("immutable");

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

var _constants = require("@instructure/quiz-common/lib/constants");

describe('#shouldFocus', function () {
  var shared = function shared(expected, deletedQuizEntry, props) {
    var fakeState = (0, _immutable.Map)({
      ui: (0, _immutable.Map)((0, _defineProperty2.default)({}, _constants.DELETED_QUIZ_ENTRY, deletedQuizEntry))
    });
    expect((0, _index.shouldFocus)(fakeState, props)).to.equal(expected);
  };

  it('returns true when position matches and both in stimulus', function () {
    shared(true, {
      position: 3,
      inStimulus: true
    }, {
      position: 3,
      stimulusId: '4'
    });
  });
  it('returns true when position matches and neither in stimulus', function () {
    shared(true, {
      position: 3,
      inStimulus: false
    }, {
      position: 3
    });
  });
  it('returns true if position is zero and first question was deleted', function () {
    shared(true, {
      position: 1,
      inStimulus: false
    }, {
      position: 0
    });
  });
  it('returns false if positions do not match', function () {
    shared(false, {
      position: 4,
      inStimulus: false
    }, {
      position: 3
    });
  });
  it('returns false if stimulus does not match', function () {
    shared(false, {
      position: 3,
      inStimulus: false
    }, {
      position: 3,
      stimulusId: '5'
    });
  });
});