"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
var __webpack_exports__ = {};
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
require("react");
const client_namespaceObject = require("@tachybase/test/client");
const demo1_js_namespaceObject = require("../demos/demo1.js");
var demo1_js_default = /*#__PURE__*/ __webpack_require__.n(demo1_js_namespaceObject);
const demo2_js_namespaceObject = require("../demos/demo2.js");
var demo2_js_default = /*#__PURE__*/ __webpack_require__.n(demo2_js_namespaceObject);
const demo3_js_namespaceObject = require("../demos/demo3.js");
var demo3_js_default = /*#__PURE__*/ __webpack_require__.n(demo3_js_namespaceObject);
const demo4_js_namespaceObject = require("../demos/demo4.js");
var demo4_js_default = /*#__PURE__*/ __webpack_require__.n(demo4_js_namespaceObject);
const demo5_js_namespaceObject = require("../demos/demo5.js");
var demo5_js_default = /*#__PURE__*/ __webpack_require__.n(demo5_js_namespaceObject);
const demo6_js_namespaceObject = require("../demos/demo6.js");
var demo6_js_default = /*#__PURE__*/ __webpack_require__.n(demo6_js_namespaceObject);
const demo7_js_namespaceObject = require("../demos/demo7.js");
var demo7_js_default = /*#__PURE__*/ __webpack_require__.n(demo7_js_namespaceObject);
const demo8_js_namespaceObject = require("../demos/demo8.js");
var demo8_js_default = /*#__PURE__*/ __webpack_require__.n(demo8_js_namespaceObject);
const demo9_js_namespaceObject = require("../demos/demo9.js");
var demo9_js_default = /*#__PURE__*/ __webpack_require__.n(demo9_js_namespaceObject);
const demo11_js_namespaceObject = require("../demos/demo11.js");
var demo11_js_default = /*#__PURE__*/ __webpack_require__.n(demo11_js_namespaceObject);
describe('DatePicker', ()=>{
    it('basic', async ()=>{
        const { container, getByText } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo1_js_default(), {}));
        await (0, client_namespaceObject.sleep)();
        const picker = container.querySelector('.ant-picker');
        const input = container.querySelector('input');
        await client_namespaceObject.userEvent.click(picker);
        await client_namespaceObject.userEvent.type(input, '2023/05/01 00:00:00');
        await client_namespaceObject.userEvent.click(getByText('OK'));
        await (0, client_namespaceObject.waitFor)(()=>{
            expect(input).toHaveValue('2023/05/01 00:00:00');
            expect(client_namespaceObject.screen.getByText('2023/05/01 00:00:00', {
                selector: '.ant-description-date-picker'
            })).toBeInTheDocument();
            if (!process.env.GITHUB_ACTIONS) expect(client_namespaceObject.screen.getByText('2023-04-30T16:00:00.000Z')).toBeInTheDocument();
        });
    });
    it('GMT', async ()=>{
        const { container, getByText } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo2_js_default(), {}));
        await (0, client_namespaceObject.sleep)();
        const picker = container.querySelector('.ant-picker');
        const input = container.querySelector('input');
        await client_namespaceObject.userEvent.click(picker);
        await client_namespaceObject.userEvent.clear(input);
        await client_namespaceObject.userEvent.type(input, '2023/05/01 00:00:00');
        await client_namespaceObject.userEvent.click(getByText('OK'));
        expect(input).toHaveValue('2023/05/01 00:00:00');
        expect(client_namespaceObject.screen.getByText('2023/05/01 00:00:00', {
            selector: '.ant-description-date-picker'
        })).toBeInTheDocument();
        expect(client_namespaceObject.screen.getByText('2023-05-01T00:00:00.000Z')).toBeInTheDocument();
    });
    it('non-UTC', async ()=>{
        const { container } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo3_js_default(), {}));
        await (0, client_namespaceObject.sleep)();
        const picker = container.querySelector('.ant-picker');
        const input = container.querySelector('input');
        await client_namespaceObject.userEvent.click(picker);
        await client_namespaceObject.userEvent.type(input, '2023/05/01');
        let selected;
        await (0, client_namespaceObject.waitFor)(()=>{
            selected = document.querySelector('.ant-picker-cell-selected');
            expect(selected).toBeInTheDocument();
        });
        await client_namespaceObject.userEvent.click(selected);
        expect(input).toHaveValue('2023/05/01');
        expect(client_namespaceObject.screen.getByText('2023/05/01 00:00:00', {
            selector: '.ant-description-date-picker'
        })).toBeInTheDocument();
        expect(client_namespaceObject.screen.getByText('2023-05-01')).toBeInTheDocument();
    });
});
describe('RangePicker', ()=>{
    it('GMT', async ()=>{
        const { container, getByPlaceholderText } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo4_js_default(), {}));
        await (0, client_namespaceObject.sleep)();
        const picker = container.querySelector('.ant-picker');
        const startInput = getByPlaceholderText('Start date');
        const endInput = getByPlaceholderText('End date');
        await client_namespaceObject.userEvent.click(picker);
        await client_namespaceObject.userEvent.click(document.querySelector('[title="2023-05-01"]'));
        await client_namespaceObject.userEvent.click(document.querySelector('[title="2023-05-02"]'));
        await (0, client_namespaceObject.waitFor)(()=>expect(startInput).toHaveValue('2023-05-01'));
        await (0, client_namespaceObject.waitFor)(()=>expect(endInput).toHaveValue('2023-05-02'));
        expect(client_namespaceObject.screen.getByText('2023-05-01~2023-05-02', {
            selector: '.ant-description-text'
        })).toBeInTheDocument();
        expect(client_namespaceObject.screen.getByText('2023-05-01T00:00:00.000Z ~ 2023-05-02T23:59:59.999Z')).toBeInTheDocument();
    });
    it('non-GMT', async ()=>{
        const { container, getByPlaceholderText } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo5_js_default(), {}));
        await (0, client_namespaceObject.sleep)();
        const picker = container.querySelector('.ant-picker');
        const startInput = getByPlaceholderText('Start date');
        const endInput = getByPlaceholderText('End date');
        await client_namespaceObject.userEvent.click(picker);
        await client_namespaceObject.userEvent.click(document.querySelector('[title="2023-05-01"]'));
        await client_namespaceObject.userEvent.click(document.querySelector('[title="2023-05-02"]'));
        await (0, client_namespaceObject.waitFor)(()=>{
            expect(startInput).toHaveValue('2023-05-01');
            expect(endInput).toHaveValue('2023-05-02');
            expect(client_namespaceObject.screen.getByText('2023-05-01~2023-05-02', {
                selector: '.ant-description-text'
            })).toBeInTheDocument();
            if (!process.env.GITHUB_ACTIONS) expect(client_namespaceObject.screen.getByText(/2023-04-30t16:00:00\.000z ~ 2023-05-02t15:59:59\.999z/i)).toBeInTheDocument();
        });
    });
    it('non-UTC', async ()=>{
        const { container, getByPlaceholderText } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo6_js_default(), {}));
        await (0, client_namespaceObject.sleep)();
        const picker = container.querySelector('.ant-picker');
        const startInput = getByPlaceholderText('Start date');
        const endInput = getByPlaceholderText('End date');
        await client_namespaceObject.userEvent.click(picker);
        await (0, client_namespaceObject.sleep)();
        await client_namespaceObject.userEvent.click(document.querySelector('[title="2023-05-01"]'));
        await client_namespaceObject.userEvent.click(document.querySelector('[title="2023-05-02"]'));
        await (0, client_namespaceObject.waitFor)(()=>expect(startInput).toHaveValue('2023-05-01'));
        await (0, client_namespaceObject.waitFor)(()=>expect(endInput).toHaveValue('2023-05-02'));
        await (0, client_namespaceObject.waitFor)(()=>expect(client_namespaceObject.screen.getByText('2023-05-01~2023-05-02', {
                selector: '.ant-description-text'
            })).toBeInTheDocument());
        await (0, client_namespaceObject.waitFor)(()=>expect(client_namespaceObject.screen.getByText('2023-05-01 ~ 2023-05-02')).toBeInTheDocument());
    });
    it('showTime=false,gmt=true,utc=true', async ()=>{
        const { container } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo7_js_default(), {}));
        await (0, client_namespaceObject.sleep)();
        const picker = container.querySelector('.ant-picker');
        const input = container.querySelector('input');
        await client_namespaceObject.userEvent.click(picker);
        await client_namespaceObject.userEvent.type(input, '2023/05/01');
        await client_namespaceObject.userEvent.click(document.querySelector('[title="2023-05-01"]'));
        await (0, client_namespaceObject.waitFor)(()=>{
            expect(input).toHaveValue('2023/05/01');
            expect(client_namespaceObject.screen.getByText('2023/05/01', {
                selector: '.ant-description-date-picker'
            })).toBeInTheDocument();
            expect(client_namespaceObject.screen.getByText('2023-05-01T00:00:00.000Z')).toBeInTheDocument();
        });
    });
    it('showTime=false,gmt=false,utc=true', async ()=>{
        const { container } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo8_js_default(), {}));
        await (0, client_namespaceObject.sleep)();
        const picker = container.querySelector('.ant-picker');
        const input = container.querySelector('input');
        await client_namespaceObject.userEvent.click(picker);
        await client_namespaceObject.userEvent.type(input, '2023/05/01');
        await client_namespaceObject.userEvent.click(document.querySelector('[title="2023-05-01"]'));
        await (0, client_namespaceObject.waitFor)(()=>{
            expect(input).toHaveValue('2023/05/01');
            expect(client_namespaceObject.screen.getByText('2023/05/01', {
                selector: '.ant-description-date-picker'
            })).toBeInTheDocument();
            if (!process.env.GITHUB_ACTIONS) expect(client_namespaceObject.screen.getByText('2023-04-30T16:00:00.000Z')).toBeInTheDocument();
        });
    });
    it('showTime=false,gmt=true,utc=true & not input', async ()=>{
        const currentDateString = new Date().toISOString().split('T')[0];
        const { container } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo9_js_default(), {}));
        await (0, client_namespaceObject.sleep)();
        const picker = container.querySelector('.ant-picker');
        await client_namespaceObject.userEvent.click(picker);
        const btn = document.querySelector('[title="'.concat(currentDateString, '"]'));
        expect(btn).toBeInTheDocument();
        await client_namespaceObject.userEvent.click(btn);
        await (0, client_namespaceObject.waitFor)(()=>{
            expect(client_namespaceObject.screen.getByText(currentDateString.replace(/-/g, '/'), {
                selector: '.ant-description-date-picker'
            })).toBeInTheDocument();
            expect(client_namespaceObject.screen.getByText("".concat(currentDateString, "T00:00:00.000Z"))).toBeInTheDocument();
        });
    });
    it('shortcut', async ()=>{
        const { container } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(demo11_js_default(), {}));
        await (0, client_namespaceObject.sleep)();
        const picker = container.querySelector('.ant-picker');
        const startInput = client_namespaceObject.screen.getByPlaceholderText('Start date');
        const endInput = client_namespaceObject.screen.getByPlaceholderText('End date');
        await client_namespaceObject.userEvent.click(picker);
        await client_namespaceObject.userEvent.click(client_namespaceObject.screen.getByText(/today/i));
        await (0, client_namespaceObject.sleep)();
        await (0, client_namespaceObject.waitFor)(()=>expect(startInput.getAttribute('value')).toBeTruthy());
        await (0, client_namespaceObject.waitFor)(()=>expect(endInput.getAttribute('value')).toBeTruthy());
    });
});
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
