"use strict";

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

var _store = _interopRequireDefault(require("store"));

var _persistedState = _interopRequireDefault(require("../persistedState"));

var _sessionStore = _interopRequireDefault(require("../sessionStore"));

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

describe('persistedState', function () {
  it('includes taking data', function () {
    var activeQuestionPosition = 2;
    var sessionId = '22';

    _store.default.set(_constants.ACTIVE_QUESTION, activeQuestionPosition);

    _store.default.set(_constants.CACHED_SESSION_ID, sessionId);

    expect(_persistedState.default.load().getIn(['taking', 'currentSessionItemPosition'])).to.be.equal(activeQuestionPosition);
    expect(_persistedState.default.load().getIn(['taking', 'sessionIdForCurrentItem'])).to.be.equal(sessionId);
  });
  it('sets the active quesiton to 1 if null', function () {
    _store.default.set(_constants.ACTIVE_QUESTION, null);

    expect(_persistedState.default.load().getIn(['taking', 'currentSessionItemPosition'])).to.be.equal(1);
  });
  it('works when local storage is disabled', function () {
    expect(_sessionStore.default.enabled).to.be.true();
    _sessionStore.default.enabled = false;
    expect(_persistedState.default.load()).to.not.be.ok();
    _sessionStore.default.enabled = true;
  });
});