"use strict";

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

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

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

var _date = require("../../../tests/testData/date");

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

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

    var _render = (0, _react.render)( /*#__PURE__*/_react2.default.createElement("div", {
      "data-testid": "date-select"
    }, /*#__PURE__*/_react2.default.createElement(_index.default, {
      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);

    _react.fireEvent.click(element === null || element === void 0 ? void 0 : element[0]);

    _react.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 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement("div", {
      "data-testid": "date-select"
    }, /*#__PURE__*/_react2.default.createElement(_index.default, {
      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);

    _react.fireEvent.click(element === null || element === void 0 ? void 0 : element[0]);

    _react.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();
  // });
});