"use strict";

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

var _Avatar = _interopRequireDefault(require("@instructure/ui-elements/lib/components/Avatar"));

var _Spinner = _interopRequireDefault(require("../../../../../common/components/shared/spinner/Spinner"));

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

var _ModerateTableRow = _interopRequireDefault(require("../../ModerateTableRow"));

describe('ModerateTable presenter', function () {
  var props = {
    tableData: [{
      avatar: 'zomgModerateTablePresenter',
      id: '42',
      name: 'lolwut',
      quizSessionIds: ['1']
    }, {
      avatar: 'lulzModerateTablePresenter',
      id: '77',
      name: 'wutlol',
      quizSessionIds: ['2']
    }],
    onModerateButtonClick: function onModerateButtonClick() {},
    onModerateLogClick: function onModerateLogClick() {}
  };
  var testbed = createTestbed(withContext(_presenter.default, {}), props);
  shouldRenderComponent(testbed, {}, _presenter.default);
  stubComponent(_Avatar.default);
  it('renders a spinner while fetching', function () {
    testbed.render({
      isFetching: true
    });
    var result = testbed.findChildByType(_Spinner.default);
    expect(result).to.be.ok();
  });
  it('includes a helpful caption', function () {
    testbed.render();
    var output = testbed.getText();
    expect(output).to.include('Moderation Table');
  });
  it('includes a helpful message without table data', function () {
    testbed.render({
      tableData: []
    });
    var output = testbed.getText();
    expect(output).to.include('There is no moderation information');
  });
  it('allows for providing a custom emptyMessage via props', function () {
    testbed.render({
      tableData: [],
      emptyMessage: 'quizzin aint easy'
    });
    var output = testbed.getText();
    expect(output).to.include('quizzin aint easy');
  });
  it('renders ModerateTableRow children as expected', function () {
    testbed.render();
    var result = testbed.findChildrenByType(_ModerateTableRow.default);
    expect(result).to.have.length(2);
  });
  it('passes onModerateLogClick to table row children', function () {
    testbed.render();
    var onModerateLogClick = testbed.findChildrenByType(_ModerateTableRow.default)[0].props.onModerateLogClick;
    expect(onModerateLogClick).to.eq(props.onModerateLogClick);
  });
});