import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import Tabs from '../index';
describe('Tab', function () {
  it('renders correctly', function () {
    var _render = render( /*#__PURE__*/React.createElement(Tabs, null, /*#__PURE__*/React.createElement(Tabs.Panel, {
      title: "\u9009\u9879\u53611"
    }, /*#__PURE__*/React.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u5DE6\u6ED1")), /*#__PURE__*/React.createElement(Tabs.Panel, {
      title: "\u9009\u9879\u53612"
    }, /*#__PURE__*/React.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u53F3\u6ED1")))),
        container = _render.container;

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

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

    expect(container).toMatchSnapshot();
  });
  it('lineWidth is auto', function () {
    var _render4 = render( /*#__PURE__*/React.createElement(Tabs, {
      lineWidth: "auto"
    }, /*#__PURE__*/React.createElement(Tabs.Panel, {
      title: "\u9009\u9879\u53611"
    }, /*#__PURE__*/React.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u5DE6\u6ED1")), /*#__PURE__*/React.createElement(Tabs.Panel, {
      title: "\u9009\u9879\u53612"
    }, /*#__PURE__*/React.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 = render( /*#__PURE__*/React.createElement(Tabs, {
      onChange: onChange,
      value: 1
    }, /*#__PURE__*/React.createElement(Tabs.Panel, {
      title: "\u9009\u9879\u53611"
    }, /*#__PURE__*/React.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u5DE6\u6ED1")), /*#__PURE__*/React.createElement(Tabs.Panel, {
      title: "\u9009\u9879\u53612"
    }, /*#__PURE__*/React.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 = render( /*#__PURE__*/React.createElement(Tabs, {
      scrollable: true,
      onChange: onChange
    }, /*#__PURE__*/React.createElement(Tabs.Panel, {
      title: "\u9009\u9879\u53611",
      disabled: true
    }, /*#__PURE__*/React.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u5DE6\u6ED1")), /*#__PURE__*/React.createElement(Tabs.Panel, {
      title: "\u9009\u9879\u53612"
    }, /*#__PURE__*/React.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u53F3\u6ED1")), /*#__PURE__*/React.createElement(Tabs.Panel, {
      title: "\u9009\u9879\u53613"
    }, /*#__PURE__*/React.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u53F3\u6ED1")))),
        container = _render6.container;

    var el = container.querySelectorAll('.za-tabs__tab');
    fireEvent.click(el[1]);
    expect(onChange).toBeCalledWith(1);
    var last = el[el.length - 1];
    fireEvent.click(last);
    expect(onChange).toBeCalledWith(2);
  });
  it('scroll tabs', function () {
    var onChange = jest.fn();

    var _render7 = render( /*#__PURE__*/React.createElement(Tabs, {
      swipeable: true,
      onChange: onChange,
      scrollable: true
    }, /*#__PURE__*/React.createElement(Tabs.Panel, {
      title: "\u9009\u9879\u53611",
      disabled: true
    }, /*#__PURE__*/React.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u5DE6\u6ED1")), /*#__PURE__*/React.createElement(Tabs.Panel, {
      title: "\u9009\u9879\u53612"
    }, /*#__PURE__*/React.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u53F3\u6ED1")), /*#__PURE__*/React.createElement(Tabs.Panel, {
      title: "\u9009\u9879\u53613"
    }, /*#__PURE__*/React.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u53F3\u6ED1")), /*#__PURE__*/React.createElement(Tabs.Panel, {
      title: "\u9009\u9879\u53614"
    }, /*#__PURE__*/React.createElement("div", null, "\u8BD5\u8BD5\u70B9\u6211\u53F3\u6ED1")), /*#__PURE__*/React.createElement(Tabs.Panel, {
      title: "\u9009\u9879\u53615"
    }, /*#__PURE__*/React.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];
    fireEvent.click(last);
    expect(onChange).toBeCalledWith(4);
  });
});