"use strict";

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

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

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

var _moderation = _interopRequireDefault(require("../moderation"));

var _immutable = require("immutable");

describe('moderationReducer', function () {
  var state = (0, _immutable.fromJS)({
    key: 'value'
  });
  context('on receiving the CLOSE_MODERATE_TRAY action', function () {
    it('sets trayOpen to false', function () {
      var action = {
        type: _constants.CLOSE_MODERATE_TRAY
      };
      expect((0, _moderation.default)(state, action).toJS()).to.deep.equal((0, _objectSpread2.default)({}, state.toJS(), {
        trayOpen: false
      }));
    });
  });
  context('on receiving the MODERATE_TRAY_CLOSED action', function () {
    it('clears selectedParticipantName', function () {
      var action = {
        type: _constants.MODERATE_TRAY_CLOSED
      };
      expect((0, _moderation.default)(state.set('selectedParticipantName', 'Bob'), action).toJS()).to.deep.equal((0, _objectSpread2.default)({}, state.toJS(), {
        selectedParticipantName: null,
        selectedSessions: []
      }));
    });
  });
  context('on receiving the OPEN_MODERATE_TRAY action', function () {
    var participant = {
      name: 'ohai',
      quizSessionIds: ['1']
    };
    var action = {
      type: _constants.OPEN_MODERATE_TRAY,
      participant: participant
    };
    it('sets trayOpen to true', function () {
      expect((0, _moderation.default)(state, action).toJS()).to.deep.include((0, _objectSpread2.default)({}, state.toJS(), {
        trayOpen: true
      }));
    });
    it('sets selectedParticipantName', function () {
      expect((0, _moderation.default)(state, action).get('selectedParticipantName')).to.equal(participant.name);
    });
    it('sets selectedSessions', function () {
      expect((0, _moderation.default)(state, action).get('selectedSessions').toJS()).to.deep.equal(['1']);
    });
  });
});