import { fireEvent, render } from '@testing-library/react';
import React from 'react';
import { date1, date2, date3, date4, date5 } from '../../../tests/testData/date';
import DateSelect from '../index';
describe('DateSelect', function () {
  it('DateSelect year', function () {
    var wrapper = render( /*#__PURE__*/React.createElement(DateSelect, {
      title: "\u9009\u62E9\u5E74\u4EFD",
      placeholder: "\u8BF7\u9009\u62E9\u5E74\u4EFD",
      columnType: ['year'],
      value: date1
    }));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('DateSelect trigger visible', function () {
    var wrapper = render( /*#__PURE__*/React.createElement(DateSelect, {
      defaultValue: date1
    }));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('DateSelect disabled', function () {
    var wrapper = render( /*#__PURE__*/React.createElement(DateSelect, {
      disabled: true,
      value: date1
    }));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('DateSelect date', function () {
    var wrapper = render( /*#__PURE__*/React.createElement(DateSelect, {
      title: "\u9009\u62E9\u65E5\u671F",
      placeholder: "\u8BF7\u9009\u62E9\u65E5\u671F",
      value: date1
    }));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('DateSelect time', function () {
    var wrapper = render( /*#__PURE__*/React.createElement(DateSelect, {
      title: "\u9009\u62E9\u65F6\u95F4",
      placeholder: "\u8BF7\u9009\u62E9\u65F6\u95F4",
      columnType: ['hour', 'minute', 'second'],
      value: date2
    }));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('DateSelect datetime', function () {
    var wrapper = render( /*#__PURE__*/React.createElement(DateSelect, {
      title: "\u9009\u62E9\u65F6\u95F4",
      placeholder: "\u8BF7\u9009\u62E9\u65F6\u95F4",
      columnType: ['year', 'month', 'day', 'hour', 'minute', 'second'],
      min: date3,
      max: date4,
      value: date5
    }));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('should trigger onConfirm when press ok button', function () {
    var onConfirmFn = jest.fn();

    var _render = render( /*#__PURE__*/React.createElement("div", {
      "data-testid": "date-select"
    }, /*#__PURE__*/React.createElement(DateSelect, {
      value: new Date('2009/3/4'),
      onConfirm: onConfirmFn
    }))),
        getByTestId = _render.getByTestId;

    var wrapper = getByTestId('date-select').getElementsByClassName('za-date-select');
    var element = [].slice.call(wrapper);
    fireEvent.click(element === null || element === void 0 ? void 0 : element[0]);
    fireEvent.click(document.body.querySelectorAll('.za-picker__confirm')[0]);
    expect(onConfirmFn).toBeCalled();
  });
  it('should trigger onCancel when press cancel button', function () {
    var onCancelFn = jest.fn();

    var _render2 = render( /*#__PURE__*/React.createElement("div", {
      "data-testid": "date-select"
    }, /*#__PURE__*/React.createElement(DateSelect, {
      value: new Date('2009/3/4'),
      onCancel: onCancelFn,
      className: "test-dateSelect"
    }))),
        getByTestId = _render2.getByTestId;

    var wrapper = getByTestId('date-select').getElementsByClassName('za-date-select');
    var element = [].slice.call(wrapper);
    fireEvent.click(element === null || element === void 0 ? void 0 : element[0]);
    fireEvent.click(document.body.querySelectorAll('.za-picker__cancel')[0]);
    expect(onCancelFn).toBeCalled();
  }); // it('should trigger onMaskClick when click mask', () => {
  //   const onMaskClick = jest.fn();
  //   const wrapper = mount(
  //     <DateSelect
  //       mode="date"
  //       value="2009-3-4"
  //       visible
  //       onMaskClick={onMaskClick}
  //     />
  //   );
  //   wrapper.find('.za-mask').simulate('click');
  //   expect(onMaskClick).toBeCalled();
  // });
});