import * as __WEBPACK_EXTERNAL_MODULE__testing_library_react__ from "@testing-library/react";
import * as __WEBPACK_EXTERNAL_MODULE__testing_library_user_event__ from "@testing-library/user-event";
import * as __WEBPACK_EXTERNAL_MODULE__RadioGroup_mjs__ from "./RadioGroup.mjs";
describe('RadioGroup', ()=>{
    test('should render radio group', ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__RadioGroup_mjs__["default"], {
            options: [
                {
                    value: '1',
                    label: 'Option 1'
                },
                {
                    value: '2',
                    label: 'Option 2',
                    disabled: true
                },
                {
                    value: '3',
                    label: 'Option 3',
                    invalid: true
                },
                {
                    value: '4',
                    label: 'Option 4',
                    invalid: true,
                    disabled: true
                }
            ],
            onChange: ()=>{},
            onBlur: ()=>{},
            value: "",
            name: "some-radio-group"
        }));
        const option1 = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByLabelText(/Option 1/i);
        const option2 = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByLabelText(/Option 2/i);
        const option3 = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByLabelText(/Option 3/i);
        const option4 = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByLabelText(/Option 4/i);
        expect(option1).toBeVisible();
        expect(option2).toBeVisible();
        expect(option3).toBeVisible();
        expect(option4).toBeVisible();
    });
    test('should be able to select option, and not select disabled option', ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__RadioGroup_mjs__["default"], {
            options: [
                {
                    value: '1',
                    label: 'Option 1'
                },
                {
                    value: '2',
                    label: 'Option 2',
                    disabled: true
                },
                {
                    value: '3',
                    label: 'Option 3',
                    invalid: true
                },
                {
                    value: '4',
                    label: 'Option 4',
                    invalid: true,
                    disabled: true
                }
            ],
            onChange: ()=>{},
            onBlur: ()=>{},
            defaultValue: "1",
            name: "some-radio-group"
        }));
        const option1 = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByLabelText(/Option 1/i);
        const option2 = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByLabelText(/Option 2/i);
        const option3 = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByLabelText(/Option 3/i);
        const option4 = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByLabelText(/Option 4/i);
        __WEBPACK_EXTERNAL_MODULE__testing_library_react__.fireEvent.click(option1);
        expect(option1).toBeChecked();
        __WEBPACK_EXTERNAL_MODULE__testing_library_react__.fireEvent.click(option2);
        expect(option1).toBeChecked();
        expect(option2).not.toBeChecked();
        __WEBPACK_EXTERNAL_MODULE__testing_library_react__.fireEvent.click(option3);
        expect(option3).toBeChecked();
        __WEBPACK_EXTERNAL_MODULE__testing_library_react__.fireEvent.click(option4);
        expect(option4).not.toBeChecked();
        expect(option3).toBeChecked();
    });
    test('should be able to use radiogroup in a controlled manner', async ()=>{
        const user = __WEBPACK_EXTERNAL_MODULE__testing_library_user_event__["default"].setup();
        const handleChange = jest.fn();
        handleChange.mockImplementation((e)=>{
            rerender(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__RadioGroup_mjs__["default"], {
                options: [
                    {
                        value: '1',
                        label: 'Option 1'
                    },
                    {
                        value: '2',
                        label: 'Option 2'
                    },
                    {
                        value: '3',
                        label: 'Option 3'
                    },
                    {
                        value: '4',
                        label: 'Option 4'
                    }
                ],
                onChange: handleChange,
                onBlur: ()=>{},
                value: e,
                name: "some-radio-group"
            }));
            expect(option1).toBeChecked();
            expect(handleChange).toHaveBeenCalledTimes(1);
            expect(handleChange).toHaveBeenCalledWith('1');
        });
        const { rerender } = (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__RadioGroup_mjs__["default"], {
            options: [
                {
                    value: '1',
                    label: 'Option 1'
                },
                {
                    value: '2',
                    label: 'Option 2'
                },
                {
                    value: '3',
                    label: 'Option 3'
                },
                {
                    value: '4',
                    label: 'Option 4'
                }
            ],
            onChange: handleChange,
            onBlur: ()=>{},
            value: "4",
            name: "some-radio-group"
        }));
        const option1 = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByLabelText(/Option 1/i);
        const option4 = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByLabelText(/Option 4/i);
        expect(option4).toBeChecked();
        await user.click(option1);
    });
});
