"use strict";

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

var _immutable = require("immutable");

var _chai = require("chai");

var _items = _interopRequireDefault(require("../items"));

var _items2 = require("../../actions/items");

var _Item = _interopRequireDefault(require("../../records/Item"));

describe('items reducer', function () {
  describe('addItem', function () {
    it('should add new items with ADD_ITEMS action', function () {
      var initialState = (0, _immutable.fromJS)({});
      var action = (0, _items2.addItems)([{
        id: '1',
        itemBody: 'qi'
      }]);
      var nextState = (0, _items.default)(initialState, action);
      var nextItem = nextState.get('1').get('itemBody');
      (0, _chai.expect)(nextItem).to.equal('qi');
    });
    it('should replace items with ADD_ITEMS action', function () {
      var initialState = (0, _immutable.fromJS)({
        1: new _Item.default({
          id: '1',
          itemBody: 'initial'
        })
      });
      var action = (0, _items2.addItems)([{
        id: '1',
        itemBody: 'nextOne'
      }, {
        id: '2',
        itemBody: 'nextTwo'
      }]);
      var nextState = (0, _items.default)(initialState, action);
      var nextItemOne = nextState.get('1').get('itemBody');
      (0, _chai.expect)(nextItemOne).to.equal('nextOne');
      var nextItemTwo = nextState.get('2').get('itemBody');
      (0, _chai.expect)(nextItemTwo).to.equal('nextTwo');
    });
  });
});