import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__ from "@tachybase/test/client";
import * as __WEBPACK_EXTERNAL_MODULE__demos_input_mjs__ from "../demos/input.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_json_mjs__ from "../demos/json.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_textarea_mjs__ from "../demos/textarea.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__demos_url_mjs__ from "../demos/url.mjs";
describe('Input', ()=>{
    it('should display the title', ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_input_mjs__["default"], {}));
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Editable').innerHTML).toBe('Editable');
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Read pretty').innerHTML).toBe('Read pretty');
    });
    it('should display the value of user input', async ()=>{
        const { container } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_input_mjs__["default"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(async ()=>{
            const input = container.querySelector('input');
            await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.type(input, 'Hello World');
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Hello World').innerHTML).toBe('Hello World');
        });
    });
});
describe('Input.TextArea', ()=>{
    it('should display the title', ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_textarea_mjs__["default"], {}));
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Editable').innerHTML).toBe('Editable');
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Read pretty').innerHTML).toBe('Read pretty');
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Read pretty(ellipsis)').innerHTML).toBe('Read pretty(ellipsis)');
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Read pretty(autop)').innerHTML).toBe('Read pretty(autop)');
    });
    it('should display the value of user input', ()=>{
        const { container } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_textarea_mjs__["default"], {}));
        const textarea = container.querySelector('textarea');
        __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.fireEvent.change(textarea, {
            target: {
                value: 'Hello World, Hello World'
            }
        });
        expect(textarea.value).toBe('Hello World, Hello World');
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getAllByText('Hello World, Hello World')).toHaveLength(4);
    });
    it('should not display undefined', ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_textarea_mjs__["default"], {}));
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.queryByText('undefined')).toBeNull();
    });
});
describe('Input.URL', ()=>{
    it('should display the title', ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_url_mjs__["default"], {}));
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Editable').innerHTML).toBe('Editable');
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Read pretty').innerHTML).toBe('Read pretty');
    });
    it('should display the value of user input', async ()=>{
        const { container } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_url_mjs__["default"], {}));
        const input = container.querySelector('input');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.type(input, 'https://www.tachybase.com');
        expect(input.value).toBe('https://www.tachybase.com');
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('https://www.tachybase.com')).toBeInTheDocument();
    });
    it('should display the error when the value is invalid', async ()=>{
        const { container } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_url_mjs__["default"], {}));
        const input = container.querySelector('input');
        await __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.userEvent.type(input, 'abcd');
        expect(input.value).toBe('abcd');
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('abcd')).toBeInTheDocument();
        expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.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, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_json_mjs__["default"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Editable').innerHTML).toBe('Editable');
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Read pretty').innerHTML).toBe('Read pretty');
        });
    });
    it('should display the value of user input', async ()=>{
        const { container } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_json_mjs__["default"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
            const textarea = container.querySelector('textarea');
            const pre = container.querySelector('pre');
            __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.fireEvent.change(textarea, {
                target: {
                    value: '{"name":"tachybase"}'
                }
            });
            __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.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, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__demos_json_mjs__["default"], {}));
        await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.waitFor)(()=>{
            const textarea = container.querySelector('textarea');
            __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.fireEvent.change(textarea, {
                target: {
                    value: '{"name":tachybase}'
                }
            });
            __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.fireEvent.blur(textarea, {
                target: {
                    value: '{"name":tachybase}'
                }
            });
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText(/Unexpected token/)).toBeInTheDocument();
        });
    });
});
