"use strict";

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

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

var _immutable = require("immutable");

var _bankEntries = _interopRequireDefault(require("../bankEntries"));

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

describe('bank entries reducer', function () {
  var initialState = (0, _immutable.fromJS)({
    1: {
      id: '1',
      entry: '399'
    },
    2: {
      id: '2',
      entry: '400'
    }
  });
  describe('addBankEntries', function () {
    it('updates state correctly', function () {
      var action = actions.addBankEntries([{
        id: '3',
        entry: '401'
      }]);
      var nextState = (0, _bankEntries.default)(initialState, action);
      expect(nextState.getIn(['1', 'entry'])).to.eq('399');
      expect(nextState.getIn(['3', 'entry'])).to.eq('401');
    });
  });
  describe('default', function () {
    it('does not update state', function () {
      var action = {
        action: 'IRRELEVANT_ACTION',
        payload: []
      };
      var nextState = (0, _bankEntries.default)(initialState, action);
      expect(nextState).to.eq(initialState);
    });
  });
  it('handles ARCHIVE_BANK_ENTRY', function () {
    var nextState = (0, _bankEntries.default)(initialState, actions.archiveBankEntry('2'));
    expect(nextState.get('2').toJS()).to.deep.equal({
      id: '2',
      entry: '400',
      archived: true
    });
  });
});