"use strict";

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

var _immutable = require("immutable");

var _chai = require("chai");

var _sessionItems = _interopRequireDefault(require("../sessionItems"));

var _sessionItems2 = require("../../actions/sessionItems");

describe('sessionItems reducer', function () {
  describe('add sessionItems', function () {
    it('should add sessionItems with ADD_SESSION_ITEMS action', function () {
      var initialState = (0, _immutable.Map)({});
      var sessionItems = [{
        item: '47',
        id: '1_1'
      }, {
        item: '48',
        id: '2_2'
      }];
      var action = (0, _sessionItems2.addSessionItems)(sessionItems);
      var nextState = (0, _sessionItems.default)(initialState, action);
      var firstID = nextState.getIn(['1_1', 'item']);
      (0, _chai.expect)(firstID).to.equal('47');
      var secondID = nextState.getIn(['2_2', 'item']);
      (0, _chai.expect)(secondID).to.equal('48');
    });
    it('should store nested data as an immutable map (not plain JS)', function () {
      var initialState = (0, _immutable.Map)({});
      var sessionItems = [{
        item: '55',
        id: '1_1',
        scoringData: {
          value: {
            foo: 'bar'
          }
        }
      }];
      var action = (0, _sessionItems2.addSessionItems)(sessionItems);
      var nextState = (0, _sessionItems.default)(initialState, action); // getIn won't work with plain JS

      var nestedValue = nextState.getIn(['1_1', 'scoringData', 'value', 'foo']);
      (0, _chai.expect)(nestedValue).to.be.equal('bar');
    });
  });
});