"use strict";

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

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

var _immutable = require("immutable");

var _Bank = _interopRequireDefault(require("../../../../common/records/Bank"));

var _index = _interopRequireWildcard(require("../index"));

describe('AddToBankModal Container', function () {
  var ConnectedAddToBankModal = withContext(_index.default, {
    banks: {
      1: {}
    }
  });
  var testbed = createTestbed(ConnectedAddToBankModal, {
    modalOpen: true,
    temporaryBank: {},
    errorsShowing: (0, _immutable.Map)(),
    createBank: sinon.stub(),
    changeBank: sinon.stub(),
    clearModifications: sinon.stub(),
    errorShowingActions: {},
    closeModal: sinon.stub()
  });
  useFakeFetching({
    dispatchStub: sinon.stub(),
    getStateStub: sinon.stub(),
    fetchStub: sinon.stub()
  });
  shouldRenderComponent(testbed, {}, _index.default);
  it('should map open modal to its entry', function () {
    var props = (0, _index.mapStateToProps)((0, _immutable.fromJS)({
      modal: {
        isOpen: 'ADD_TO_BANK_MODAL:Item:1'
      }
    }), {
      entryId: '1',
      entryType: 'Item'
    });
    expect(props.modalOpen).to.be.true();
  });
  it('should map modal selection state to Bank record', function () {
    var props = (0, _index.mapStateToProps)((0, _immutable.fromJS)({
      banks: {
        2: {
          title: 'Excellent Bank'
        }
      },
      ui: {
        ADD_TO_BANK_MODAL_BANK_SELECTION: '2'
      }
    }), {});
    expect(props.selectedBank).to.be.an.instanceof(_Bank.default);
    expect(props.selectedBank.title).to.eq('Excellent Bank');
  });
});