"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

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

var _immutable = require("immutable");

var _QuizSession = _interopRequireDefault(require("../../../../../common/records/QuizSession"));

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

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

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

describe('ModerateTableRow', function () {
  var props = {
    onModerateLogClick: function onModerateLogClick() {},
    rowData: {
      name: 'lolwut',
      avatar: 'zomg',
      quizSessionIds: ['1']
    },
    quizSessions: (0, _immutable.List)(new _QuizSession.default({
      id: '1'
    }))
  };
  var testbedWithContext = createTestbed(withContext(_index.default, {}), props);
  shouldRenderComponent(testbedWithContext, {}, _index.default);
  describe('mapStateToProps', function () {
    afterEach(function () {
      (0, _reduxStore.unsetFakeStore)();
    });
    it('receives quizSessions from state', function () {
      var fakeState = (0, _immutable.fromJS)({
        quizSessions: {
          1: {
            id: '1'
          }
        }
      });
      (0, _reduxStore.setFakeStore)(fakeState);

      var _mapStateToProps = (0, _index.mapStateToProps)({}, props),
          quizSessions = _mapStateToProps.quizSessions;

      expect(quizSessions).to.be.instanceOf(_immutable.List);
      expect(quizSessions.size).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

        }
      });
      (0, _reduxStore.setFakeStore)(fakeState);

      var _mapStateToProps2 = (0, _index.mapStateToProps)({}, props),
          quizSessions = _mapStateToProps2.quizSessions;

      expect(quizSessions).to.be.instanceOf(_immutable.List);
      expect(quizSessions.size).to.eq(0);
    });
    it('filters to exclude pending quizSessions', function () {
      var fakeState = (0, _immutable.fromJS)({
        quizSessions: {
          1: {
            id: '1',
            status: _constants.PENDING
          }
        }
      });
      (0, _reduxStore.setFakeStore)(fakeState);

      var _mapStateToProps3 = (0, _index.mapStateToProps)({}, props),
          quizSessions = _mapStateToProps3.quizSessions;

      expect(quizSessions).to.be.instanceOf(_immutable.List);
      expect(quizSessions.size).to.eq(0);
    });
  });
});