"use strict";

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

var _List = require("../List");

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

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

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('List', function () {
  describe('Row', function () {
    var shallowWrapper, hasBeenClicked;
    describe('Without expansion', function () {
      var clickMe = function clickMe() {
        hasBeenClicked = true;
      };

      beforeEach(function () {
        hasBeenClicked = false;
        shallowWrapper = (0, _enzyme.shallow)(_react.default.createElement(_List.Row, {
          id: "hello",
          onClick: clickMe
        }, _react.default.createElement("div", null, "Hi")));
      });
      test('should handle an onClick function', function () {
        shallowWrapper.simulate('click');
        expect(hasBeenClicked).toBe(true);
      });
      test('should be able to find its id', function () {
        expect(shallowWrapper.prop('id')).toEqual('hello');
      });
      test('should have children', function () {
        expect(shallowWrapper.contains(_react.default.createElement("div", null, "Hi"))).toBe(true);
      });
    });
    describe('With expansion', function () {
      test('should contain an ExpansionNode', function () {
        var expansion = 'I am now expanded';
        shallowWrapper = (0, _enzyme.shallow)(_react.default.createElement(_List.Row, {
          expansion: expansion
        }, _react.default.createElement("div", null, "Hi")));
        expect(shallowWrapper.contains(expansion)).toBe(true);
      });
    });
  });
  describe('Action Button', function () {
    var shallowWrapper,
        hasBeenClicked = false;

    var onClick = function onClick() {
      hasBeenClicked = true;
    },
        icon = 'fa fa-plus',
        className = 'some-class other-class';

    beforeEach(function () {
      hasBeenClicked = false;
      shallowWrapper = (0, _enzyme.shallow)(_react.default.createElement(_List.ActionButton, {
        icon: icon,
        className: className,
        onClick: onClick
      }));
    });
    test('should append icon and className together', function () {
      expect(shallowWrapper.find('span').prop('className')).toEqual("".concat(icon, " ").concat(className));
    });
    test('should have onClick prop registered', function () {
      shallowWrapper.simulate('click');
      expect(hasBeenClicked).toEqual(true);
    });
  });
});