"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 input_js_namespaceObject = require("../demos/input.js");
var input_js_default = /*#__PURE__*/ __webpack_require__.n(input_js_namespaceObject);
const json_js_namespaceObject = require("../demos/json.js");
var json_js_default = /*#__PURE__*/ __webpack_require__.n(json_js_namespaceObject);
const textarea_js_namespaceObject = require("../demos/textarea.js");
var textarea_js_default = /*#__PURE__*/ __webpack_require__.n(textarea_js_namespaceObject);
const url_js_namespaceObject = require("../demos/url.js");
var url_js_default = /*#__PURE__*/ __webpack_require__.n(url_js_namespaceObject);
describe('Input', ()=>{
    it('should display the title', ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_js_default(), {}));
        expect(client_namespaceObject.screen.getByText('Editable').innerHTML).toBe('Editable');
        expect(client_namespaceObject.screen.getByText('Read pretty').innerHTML).toBe('Read pretty');
    });
    it('should display the value of user input', async ()=>{
        const { container } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_js_default(), {}));
        await (0, client_namespaceObject.waitFor)(async ()=>{
            const input = container.querySelector('input');
            await client_namespaceObject.userEvent.type(input, 'Hello World');
            expect(client_namespaceObject.screen.getByText('Hello World').innerHTML).toBe('Hello World');
        });
    });
});
describe('Input.TextArea', ()=>{
    it('should display the title', ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(textarea_js_default(), {}));
        expect(client_namespaceObject.screen.getByText('Editable').innerHTML).toBe('Editable');
        expect(client_namespaceObject.screen.getByText('Read pretty').innerHTML).toBe('Read pretty');
        expect(client_namespaceObject.screen.getByText('Read pretty(ellipsis)').innerHTML).toBe('Read pretty(ellipsis)');
        expect(client_namespaceObject.screen.getByText('Read pretty(autop)').innerHTML).toBe('Read pretty(autop)');
    });
    it('should display the value of user input', ()=>{
        const { container } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(textarea_js_default(), {}));
        const textarea = container.querySelector('textarea');
        client_namespaceObject.fireEvent.change(textarea, {
            target: {
                value: 'Hello World, Hello World'
            }
        });
        expect(textarea.value).toBe('Hello World, Hello World');
        expect(client_namespaceObject.screen.getAllByText('Hello World, Hello World')).toHaveLength(4);
    });
    it('should not display undefined', ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(textarea_js_default(), {}));
        expect(client_namespaceObject.screen.queryByText('undefined')).toBeNull();
    });
});
describe('Input.URL', ()=>{
    it('should display the title', ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(url_js_default(), {}));
        expect(client_namespaceObject.screen.getByText('Editable').innerHTML).toBe('Editable');
        expect(client_namespaceObject.screen.getByText('Read pretty').innerHTML).toBe('Read pretty');
    });
    it('should display the value of user input', async ()=>{
        const { container } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(url_js_default(), {}));
        const input = container.querySelector('input');
        await client_namespaceObject.userEvent.type(input, 'https://www.tachybase.com');
        expect(input.value).toBe('https://www.tachybase.com');
        expect(client_namespaceObject.screen.getByText('https://www.tachybase.com')).toBeInTheDocument();
    });
    it('should display the error when the value is invalid', async ()=>{
        const { container } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(url_js_default(), {}));
        const input = container.querySelector('input');
        await client_namespaceObject.userEvent.type(input, 'abcd');
        expect(input.value).toBe('abcd');
        expect(client_namespaceObject.screen.getByText('abcd')).toBeInTheDocument();
        expect(client_namespaceObject.screen.getByText('The field value is a invalid url').innerHTML).toBe('The field value is a invalid url');
    });
});
describe('Input.JSON', ()=>{
    it('should display the title', async ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(json_js_default(), {}));
        await (0, client_namespaceObject.waitFor)(()=>{
            expect(client_namespaceObject.screen.getByText('Editable').innerHTML).toBe('Editable');
            expect(client_namespaceObject.screen.getByText('Read pretty').innerHTML).toBe('Read pretty');
        });
    });
    it('should display the value of user input', async ()=>{
        const { container } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(json_js_default(), {}));
        await (0, client_namespaceObject.waitFor)(()=>{
            const textarea = container.querySelector('textarea');
            const pre = container.querySelector('pre');
            client_namespaceObject.fireEvent.change(textarea, {
                target: {
                    value: '{"name":"tachybase"}'
                }
            });
            client_namespaceObject.fireEvent.blur(textarea, {
                target: {
                    value: '{"name":"tachybase"}'
                }
            });
            expect(JSON.parse(textarea.value)).toEqual({
                name: 'tachybase'
            });
            expect(pre).toMatchInlineSnapshot('\n      <pre\n        class="ant-json css-4dta7v"\n      >\n        {\n        "name": "tachybase"\n      }\n      </pre>\n    ');
        });
    });
    it('should display the error when the value is invalid', async ()=>{
        const { container } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(json_js_default(), {}));
        await (0, client_namespaceObject.waitFor)(()=>{
            const textarea = container.querySelector('textarea');
            client_namespaceObject.fireEvent.change(textarea, {
                target: {
                    value: '{"name":tachybase}'
                }
            });
            client_namespaceObject.fireEvent.blur(textarea, {
                target: {
                    value: '{"name":tachybase}'
                }
            });
            expect(client_namespaceObject.screen.getByText(/Unexpected token/)).toBeInTheDocument();
        });
    });
});
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
});
