"use strict";

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

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

var _react2 = require("@testing-library/react");

var _index = _interopRequireDefault(require("../index"));

describe('Tab', function () {
  it('renders correctly', function () {
    var _render = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, null, /*#__PURE__*/_react.default.createElement(_index.default.Panel, {
      title: "\u9009\u9879\u53611"
    }, /*#__PURE__*/_react.default.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u5DE6\u6ED1")), /*#__PURE__*/_react.default.createElement(_index.default.Panel, {
      title: "\u9009\u9879\u53612"
    }, /*#__PURE__*/_react.default.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u53F3\u6ED1")))),
        container = _render.container;

    expect(container).toMatchSnapshot();
  });
  it('renders correctly vertical', function () {
    var _render2 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      direction: "vertical"
    }, /*#__PURE__*/_react.default.createElement(_index.default.Panel, {
      title: "\u9009\u9879\u53611"
    }, /*#__PURE__*/_react.default.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u5DE6\u6ED1")), /*#__PURE__*/_react.default.createElement(_index.default.Panel, {
      title: "\u9009\u9879\u53612"
    }, /*#__PURE__*/_react.default.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u53F3\u6ED1")))),
        container = _render2.container;

    expect(container).toMatchSnapshot();
  });
  it('canSwipe', function () {
    var _render3 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      swipeable: true
    }, /*#__PURE__*/_react.default.createElement(_index.default.Panel, {
      title: "\u9009\u9879\u53611"
    }, /*#__PURE__*/_react.default.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u5DE6\u6ED1")), /*#__PURE__*/_react.default.createElement(_index.default.Panel, {
      title: "\u9009\u9879\u53612"
    }, /*#__PURE__*/_react.default.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u53F3\u6ED1")))),
        container = _render3.container;

    expect(container).toMatchSnapshot();
  });
  it('lineWidth is auto', function () {
    var _render4 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      lineWidth: "auto"
    }, /*#__PURE__*/_react.default.createElement(_index.default.Panel, {
      title: "\u9009\u9879\u53611"
    }, /*#__PURE__*/_react.default.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u5DE6\u6ED1")), /*#__PURE__*/_react.default.createElement(_index.default.Panel, {
      title: "\u9009\u9879\u53612"
    }, /*#__PURE__*/_react.default.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u53F3\u6ED1")))),
        container = _render4.container;

    expect(container).toMatchSnapshot();
  });
  it('receive new value', function () {
    var onChange = jest.fn();

    var _render5 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      onChange: onChange,
      value: 1
    }, /*#__PURE__*/_react.default.createElement(_index.default.Panel, {
      title: "\u9009\u9879\u53611"
    }, /*#__PURE__*/_react.default.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u5DE6\u6ED1")), /*#__PURE__*/_react.default.createElement(_index.default.Panel, {
      title: "\u9009\u9879\u53612"
    }, /*#__PURE__*/_react.default.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u53F3\u6ED1")))),
        container = _render5.container;

    expect(container).toMatchSnapshot();
  });
  it('click tabs', function () {
    var onChange = jest.fn();

    var _render6 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      scrollable: true,
      onChange: onChange
    }, /*#__PURE__*/_react.default.createElement(_index.default.Panel, {
      title: "\u9009\u9879\u53611",
      disabled: true
    }, /*#__PURE__*/_react.default.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u5DE6\u6ED1")), /*#__PURE__*/_react.default.createElement(_index.default.Panel, {
      title: "\u9009\u9879\u53612"
    }, /*#__PURE__*/_react.default.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u53F3\u6ED1")), /*#__PURE__*/_react.default.createElement(_index.default.Panel, {
      title: "\u9009\u9879\u53613"
    }, /*#__PURE__*/_react.default.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u53F3\u6ED1")))),
        container = _render6.container;

    var el = container.querySelectorAll('.za-tabs__tab');

    _react2.fireEvent.click(el[1]);

    expect(onChange).toBeCalledWith(1);
    var last = el[el.length - 1];

    _react2.fireEvent.click(last);

    expect(onChange).toBeCalledWith(2);
  });
  it('scroll tabs', function () {
    var onChange = jest.fn();

    var _render7 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      swipeable: true,
      onChange: onChange,
      scrollable: true
    }, /*#__PURE__*/_react.default.createElement(_index.default.Panel, {
      title: "\u9009\u9879\u53611",
      disabled: true
    }, /*#__PURE__*/_react.default.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u5DE6\u6ED1")), /*#__PURE__*/_react.default.createElement(_index.default.Panel, {
      title: "\u9009\u9879\u53612"
    }, /*#__PURE__*/_react.default.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u53F3\u6ED1")), /*#__PURE__*/_react.default.createElement(_index.default.Panel, {
      title: "\u9009\u9879\u53613"
    }, /*#__PURE__*/_react.default.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u53F3\u6ED1")), /*#__PURE__*/_react.default.createElement(_index.default.Panel, {
      title: "\u9009\u9879\u53614"
    }, /*#__PURE__*/_react.default.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u53F3\u6ED1")), /*#__PURE__*/_react.default.createElement(_index.default.Panel, {
      title: "\u9009\u9879\u53615"
    }, /*#__PURE__*/_react.default.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u53F3\u6ED1")))),
        container = _render7.container;

    var el = container.querySelectorAll('.za-tabs__tab');
    var last = el[el.length - 1];

    _react2.fireEvent.click(last);

    expect(onChange).toBeCalledWith(4);
  });
});