"use strict";

var _react = _interopRequireDefault(require("react"));

var _enzyme = require("enzyme");

var _BarChart = _interopRequireDefault(require("./BarChart"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var simpleData = [{
  x: 100,
  y: 1
}, {
  x: 200,
  y: 2
}, {
  x: 300,
  y: 3
}, {
  x: 400,
  y: 4
}];
var customData = [{
  x: 100,
  y: 1
}, {
  x: 200,
  y: 2
}, {
  x: 300,
  y: 3
}, {
  x: 400,
  y: 4
}, {
  x: 500,
  y: 5
}];
var simpleDataDomain = {
  x: [100, 400],
  y: [0, 4]
};
var customDataDomain = {
  x: [100, 500],
  y: [0, 5]
};
describe("BarChart", function () {
  it("renders a VictoryChart", function () {
    var wrapper = (0, _enzyme.shallow)(_react["default"].createElement(_BarChart["default"], {
      data: simpleData
    }));
    expect(wrapper.find("VictoryChart").length).to.eql(1);
  });
  it("renders a BarChart with simple data", function () {
    var wrapper = (0, _enzyme.shallow)(_react["default"].createElement(_BarChart["default"], {
      data: simpleData
    }));
    expect(wrapper.find({
      title: "Bar Chart"
    }).length).to.eql(1);
    expect(wrapper.find({
      title: "Bar Chart"
    }).props().data).to.eql([{
      dataKey: 100,
      dataValue: 1,
      label: "X: 100 • Y: 1"
    }, {
      dataKey: 200,
      dataValue: 2,
      label: "X: 200 • Y: 2"
    }, {
      dataKey: 300,
      dataValue: 3,
      label: "X: 300 • Y: 3"
    }, {
      dataKey: 400,
      dataValue: 4,
      label: "X: 400 • Y: 4"
    }]);
  });
  it("renders an updated BarChart when passed new data", function () {
    var wrapper = (0, _enzyme.shallow)(_react["default"].createElement(_BarChart["default"], {
      data: simpleData
    }));
    expect(wrapper.find({
      title: "Bar Chart"
    }).length).to.eql(1);
    wrapper.setProps({
      data: customData
    });
    expect(wrapper.find({
      title: "Bar Chart"
    }).props().data).to.eql([{
      dataKey: 100,
      dataValue: 1,
      label: "X: 100 • Y: 1"
    }, {
      dataKey: 200,
      dataValue: 2,
      label: "X: 200 • Y: 2"
    }, {
      dataKey: 300,
      dataValue: 3,
      label: "X: 300 • Y: 3"
    }, {
      dataKey: 400,
      dataValue: 4,
      label: "X: 400 • Y: 4"
    }, {
      dataKey: 500,
      dataValue: 5,
      label: "X: 500 • Y: 5"
    }]);
  });
  it("renders both axes", function () {
    var wrapper = (0, _enzyme.shallow)(_react["default"].createElement(_BarChart["default"], {
      data: simpleData
    }));
    var axes = wrapper.find("VictoryAxis");
    var xAxis = wrapper.find({
      title: "X Axis"
    });
    var yAxis = wrapper.find({
      title: "Y Axis"
    });
    expect(axes.length).to.eql(2);
    expect(xAxis.length).to.eql(1);
    expect(yAxis.length).to.eql(1);
  });
  it("should properly set a domain based on the data if not provided with one", function () {
    var wrapper = (0, _enzyme.shallow)(_react["default"].createElement(_BarChart["default"], {
      data: simpleData
    }));
    var chart = wrapper.find("VictoryChart");
    expect(chart.props().domain).to.eql(simpleDataDomain);
  });
  it("should properly set a domain if provided with one", function () {
    var wrapper = (0, _enzyme.shallow)(_react["default"].createElement(_BarChart["default"], {
      data: simpleData,
      domain: customDataDomain
    }));
    var chart = wrapper.find("VictoryChart");
    expect(chart.props().domain).to.eql(customDataDomain);
  });
});