"use strict";

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

var _immutable = require("immutable");

var _Select = _interopRequireDefault(require("@instructure/ui-forms/lib/components/Select"));

var _presenter = _interopRequireDefault(require("../presenter"));

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

describe('BankSelection', function () {
  var bankSelectionProps = {
    banks: (0, _immutable.fromJS)([new _Bank.default({
      id: '1'
    }), new _Bank.default({
      id: '2'
    })]),
    selectedBank: new _Bank.default({
      id: '1'
    })
  };
  var testbed = createTestbed(_presenter.default, bankSelectionProps);
  var shallowtestbed = testbed.renderShallowly();
  it('renders the Select component', function () {
    expect(shallowtestbed.find(_Select.default).length).to.equal(1);
  });
  it('renders all the banks as options', function () {
    var autocomplete = shallowtestbed.find(_Select.default);
    var options = autocomplete.find('option');
    expect(options.length).to.equal(2);
  });
  it('renders errors if the selected bank is archived', function () {
    var errorRender = testbed.renderShallowly({
      selectedBank: new _Bank.default({
        archived: true
      })
    });
    var autocomplete = errorRender.find(_Select.default);
    expect(autocomplete.prop('messages').length).to.eq(1);
    expect(autocomplete.prop('messages')[0].type).to.eq('error');
    expect(autocomplete.prop('messages')[0].text).to.include('Please select a valid bank');
  });
});