"use strict";

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

var _immutable = require("immutable");

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

var _quizSessionEvents = _interopRequireDefault(require("../quizSessionEvents"));

describe('quizSessionEvents reducer', function () {
  describe('adding events', function () {
    var eventA = {
      createdAt: 'yesterday',
      quizSessionId: 'lol'
    };
    var eventB = {
      createdAt: 'a bit ago',
      quizSessionId: 'lol'
    };
    var eventC = {
      createdAt: 'just now',
      quizSessionId: 'lol'
    };
    it('creates a new events list for a new quizSessionId', function () {
      var action = {
        type: _constants.ADD_QUIZ_SESSION_EVENTS,
        payload: [eventA]
      };
      var nextState = (0, _quizSessionEvents.default)(void 0, action);
      var expectedNextState = (0, _immutable.fromJS)({
        lol: [eventA]
      });
      expect((0, _immutable.is)(nextState, expectedNextState)).to.be.true();
    });
    it('concats the events list for a preexisting quizSessionId', function () {
      var action = {
        type: _constants.ADD_QUIZ_SESSION_EVENTS,
        payload: [eventB, eventC]
      };
      var currentState = (0, _immutable.fromJS)({
        lol: [eventA]
      });
      var nextState = (0, _quizSessionEvents.default)(currentState, action);
      var expectedNextState = (0, _immutable.fromJS)({
        lol: [eventA, eventB, eventC]
      });
      expect((0, _immutable.is)(nextState, expectedNextState)).to.be.true();
    });
  });
});