"use strict";

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

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

var styles = {
  componentId: 'fGOwX',
  template: function template(theme) {
    return "\n\n.Distribution__styles__bar {\n  fill: ".concat(theme.barFillColor || 'inherit', ";\n}\n\n.Distribution__styles__barStar {\n  fill: ").concat(theme.barStarFillColor || 'inherit', ";\n}\n\n.Distribution__styles__barContainer {\n}\n\n.Distribution__styles__xAxis {\n  color: ").concat(theme.xAxisColor || 'inherit', ";\n}\n\n.Distribution__styles__barLabel {\n  color: ").concat(theme.barLabelColor || 'inherit', ";\n  font-family: ").concat(theme.barLabelFontFamily || 'inherit', ";\n  font-size: ").concat(theme.barLabelFontSize || 'inherit', ";\n  text-anchor: middle;\n}\n");
  },
  'bar': 'Distribution__styles__bar',
  'barStar': 'Distribution__styles__barStar',
  'barContainer': 'Distribution__styles__barContainer',
  'xAxis': 'Distribution__styles__xAxis',
  'barLabel': 'Distribution__styles__barLabel'
};
describe('QuintileDistribution', function () {
  var quintile = [1, 3, 5, 3, 1];
  var quintileRangeLabels = ['0-19%', '20-39%', '40-59%', '60-79%', '80-100%'];
  var testbed = createTestbed(_presenter.default, {
    animateDelay: null,
    animateDuration: null,
    barPaddingInner: 0,
    barPaddingOuter: 0,
    chartWidth: 100,
    visualDistribution: quintile
  });
  shouldRenderComponent(testbed, {}, _presenter.default);
  it('should render ticks with bin range', function () {
    testbed.render();
    var ticks = testbed.findChildrenBySelector(".".concat(styles.xAxis, " g.tick"));
    expect(ticks.map(function (t) {
      return t.textContent;
    })).to.eql(quintileRangeLabels);
  });
  it('should render bar labels', function () {
    testbed.render();
    var labels = testbed.findChildrenBySelector(".".concat(styles.barContainer, " text"));
    expect(labels.length).to.eq(5);
    labels.forEach(function (l, i) {
      expect(l.textContent).to.eq(quintile[i].toString());
      expect(l.attributes.x.value).to.eq((i * 20 + 10).toString());
      expect(l.attributes.y.value > 0).to.eq(true);
    });
  });
  it('renders a table containing the raw chart data', function () {
    testbed.render();
    var tbody = testbed.findChildByTagName('tbody');
    var tableRows = tbody.querySelectorAll('tr');
    expect(tableRows).to.have.length(5);
    tableRows.forEach(function (tableRow, index) {
      var columns = tableRow.querySelectorAll('td');
      expect(testbed.getText(columns[0])).to.eq(quintileRangeLabels[index]);
      expect(testbed.getText(columns[1])).to.eq("".concat(quintile[index]));
    });
  });
});