"use strict";

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

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

var _lodash = _interopRequireDefault(require("lodash"));

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

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

var _immutable = require("immutable");

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

var _TagSuggestSelect = _interopRequireDefault(require("../../../../common/components/shared/TagSuggestSelect"));

describe('BankSearch', function () {
  var screenreaderNotificationStub = sinon.stub();
  var testbed = createTestbed(_presenter.default, {
    search: (0, _immutable.fromJS)({
      interactionTypes: (0, _immutable.Set)()
    }),
    showFilters: false,
    searching: false,
    toggle: sinon.stub(),
    toggleFilters: sinon.stub(),
    update: sinon.stub(),
    screenreaderNotification: screenreaderNotificationStub
  });
  it('renders a TextInput component', function () {
    var output = testbed.renderShallowly();
    expect(output.find(_TextInput.default)).to.have.length(1);
  });
  it('renders interaction types', function () {
    var output = testbed.renderShallowly({
      showFilters: true,
      interactionTypes: [{
        count: 10,
        interaction_type: {
          id: '10',
          name: 'True / False'
        }
      }, {
        count: 5,
        interaction_type: {
          id: '11',
          name: 'Multiple Choice'
        }
      }]
    });
    expect(output.find(_Checkbox.default)).to.have.length(2);
  });
  it('renders suggested tags', function () {
    var output = testbed.renderShallowly({
      showFilters: true,
      tags: [{
        tag: {
          id: '1',
          value: 'africa'
        }
      }, {
        tag: {
          id: '1',
          value: 'asia'
        }
      }]
    });
    expect(output.find(_TagSuggestSelect.default).props().defaultSuggestions).to.have.length(2);
  });
  it('hides interaction types until toggled', function () {
    var it = function it(id) {
      return {
        count: 10,
        interaction_type: {
          id: id,
          name: 'True / False'
        }
      };
    };

    var props = {
      interactionTypes: _lodash.default.range(10).map(function (i) {
        return it(i.toString());
      }),
      showFilters: true
    };
    var hidden = testbed.renderShallowly(props);
    expect(hidden.find(_Checkbox.default)).to.have.length(5);
    var shown = testbed.renderShallowly((0, _objectSpread2.default)({}, props, {
      allInteractions: true
    }));
    expect(shown.find(_Checkbox.default)).to.have.length(10);
  });
  it('should meet a11y standards', function (done) {
    testbed.renderShallowly();
    testbed.checkA11yStandards(done);
  });
});