"use strict";

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

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

var _immutable = require("immutable");

var _reporting = _interopRequireDefault(require("../reporting"));

var actions = _interopRequireWildcard(require("../../actions/reporting"));

describe('reporting reducer', function () {
  describe('addItemAnalyses', function () {
    it('updates state correctly', function () {
      var initialState = (0, _immutable.fromJS)({});
      var action = actions.addItemAnalyses([{
        itemId: '1',
        points: 1
      }]);
      var nextState = (0, _reporting.default)(initialState, action);
      var nextAnalysisState = nextState.getIn(['item_analysis', '1']).get('points');
      expect(nextAnalysisState).to.equal(1);
    });
  });
  describe('addQuizAnalysis', function () {
    it('updates state correctly', function () {
      var initialState = (0, _immutable.fromJS)({});
      var action = actions.addQuizAnalysis([{
        quizId: '1',
        points: 2
      }]);
      var nextState = (0, _reporting.default)(initialState, action);
      var nextAnalysisState = nextState.getIn(['quiz_analysis', '1']).get('points');
      expect(nextAnalysisState).to.equal(2);
    });
  });
  describe('QuizAnalysisNotFound', function () {
    it('updates state correctly', function () {
      var initialState = (0, _immutable.fromJS)({});
      var action = actions.markQuizAnalysisNotFound('1');
      var nextState = (0, _reporting.default)(initialState, action);
      var nextAnalysisState = nextState.getIn(['quiz_analysis', '1']).get('notFound');
      expect(nextAnalysisState).to.equal(true);
    });
  });
  describe('ItemAnalysisNotFound', function () {
    it('updates state correctly', function () {
      var initialState = (0, _immutable.fromJS)({});
      var action = actions.markItemAnalysisNotFound('1');
      var nextState = (0, _reporting.default)(initialState, action);
      var nextAnalysisState = nextState.getIn(['item_analysis', '1']).get('notFound');
      expect(nextAnalysisState).to.equal(true);
    });
  });
  describe('toggleItemAnalysisRow', function () {
    it('updates state correctly', function () {
      var initialState = (0, _immutable.fromJS)({
        item_analysis_row_open: {
          1: {
            isOpen: true
          }
        }
      });
      var action = actions.toggleItemAnalysisRowExpanded('1');
      var nextState = (0, _reporting.default)(initialState, action);
      var nextAnalysisState = nextState.getIn(['item_analysis_row_open', '1']);
      expect(nextAnalysisState).to.equal(false);
    });
  });
});