"use strict";

var _immutable = require("immutable");

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

var _reduxStore = require("../../../../../reduxStore");

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

describe('ResetQuiz', function () {
  describe('mapStateToProps', function () {
    afterEach(function () {
      (0, _reduxStore.unsetFakeStore)();
    });
    it('passes open/closed state to the component', function () {
      var fakeState = (0, _immutable.fromJS)({
        quizSessions: {
          1: {
            id: '1'
          }
        },
        moderation: {
          selectedSessions: {
            id: '1'
          }
        }
      });
      (0, _reduxStore.setFakeStore)(fakeState);

      var _mapStateToProps = (0, _index.mapStateToProps)(fakeState),
          sessionId = _mapStateToProps.sessionId;

      expect(sessionId).to.eq('1');
    });
    it('filters to use only loaded quizSessions', function () {
      var fakeState = (0, _immutable.fromJS)({
        quizSessions: {
          1: {
            id: '0'
          }
        },
        // NOTE: 0 id means it has not loaded
        moderation: {
          selectedSessions: {
            id: '1'
          }
        }
      });
      (0, _reduxStore.setFakeStore)(fakeState);

      var _mapStateToProps2 = (0, _index.mapStateToProps)(fakeState),
          sessionId = _mapStateToProps2.sessionId;

      expect(sessionId).not.to.exist();
    });
    it('filters to exclude pending quizSessions', function () {
      var fakeState = (0, _immutable.fromJS)({
        quizSessions: {
          1: {
            id: '1',
            status: _constants.PENDING
          }
        },
        moderation: {
          selectedSessions: {
            id: '1'
          }
        }
      });
      (0, _reduxStore.setFakeStore)(fakeState);

      var _mapStateToProps3 = (0, _index.mapStateToProps)(fakeState),
          sessionId = _mapStateToProps3.sessionId;

      expect(sessionId).not.to.exist();
    });
    it('marks in_progress sessions as incomplete', function () {
      var fakeState = (0, _immutable.fromJS)({
        quizSessions: {
          1: {
            id: '1',
            status: _constants.IN_PROGRESS
          }
        },
        moderation: {
          selectedSessions: {
            id: '1'
          }
        }
      });
      (0, _reduxStore.setFakeStore)(fakeState);

      var _mapStateToProps4 = (0, _index.mapStateToProps)(fakeState),
          isComplete = _mapStateToProps4.isComplete;

      expect(isComplete).to.be.false();
    });
    it('marks graded sessions as complete', function () {
      var fakeState = (0, _immutable.fromJS)({
        quizSessions: {
          1: {
            id: '1',
            status: _constants.GRADED
          }
        },
        moderation: {
          selectedSessions: {
            id: '1'
          }
        }
      });
      (0, _reduxStore.setFakeStore)(fakeState);

      var _mapStateToProps5 = (0, _index.mapStateToProps)(fakeState),
          isComplete = _mapStateToProps5.isComplete;

      expect(isComplete).to.be.true();
    });
  });
});