"use strict";

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

var _enzyme = _interopRequireWildcard(require("enzyme"));

var _ = require("..");

var _enzymeAdapterReact = _interopRequireDefault(require("enzyme-adapter-react-16"));

var _AnalyticCard = require("../../../../lib/components/AnalyticCard");

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }

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

_enzyme.default.configure({
  adapter: new _enzymeAdapterReact.default()
});

describe('analytic card', function () {
  it('should pass in onClick if given and have vs-analytic-card-clickable classname', function () {
    var onClick = jest.fn();
    var wrapper = (0, _enzyme.mount)(_react.default.createElement(_.AnalyticCard, {
      onClick: onClick
    }));
    wrapper.find('div.vs-analytic-card-clickable').props().onClick();
    expect(onClick.mock.calls).toHaveLength(1);
  });
  it('should render children that are passed in', function () {
    var child = _react.default.createElement("div", null, "i am baby");

    var wrapper = (0, _enzyme.mount)(_react.default.createElement(_.AnalyticCard, {
      children: child
    }));
    expect(wrapper.find('div.vs-analytic-card').props().children).toEqual(child);
  });
  it('should not have vs-analytic-card-clickable classname when no onclicks are passed in', function () {
    var wrapper = (0, _enzyme.mount)(_react.default.createElement(_.AnalyticCard, null));
    expect(wrapper.find('div.vs-analytic-card-clickable')).toEqual({});
  });
});
describe('View Detail Button', function () {
  it('should trigger onClick handler when clicking on the button', function () {
    var onClick = jest.fn();
    var wrapper = (0, _enzyme.mount)(_react.default.createElement(_AnalyticCard.ViewDetailButton, {
      onClick: onClick
    }));
    wrapper.find('button.vs-analytic-card-view-detail-button').simulate('click');
    expect(onClick.mock.calls).toHaveLength(1);
  });
});