import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__testing_library_react__ from "@testing-library/react";
import * as __WEBPACK_EXTERNAL_MODULE__SearchField_mjs__ from "./SearchField.mjs";
describe('SearchField', ()=>{
    test('should show search-icon-focus if empty', ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__SearchField_mjs__["default"], {
            searchText: "",
            setSearchText: ()=>{}
        }));
        const focusIcon = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.queryByLabelText('search-icon-focus');
        const resetIcon = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.queryByLabelText('search-icon-reset');
        expect(focusIcon).toBeInTheDocument();
        expect(resetIcon).not.toBeInTheDocument();
    });
    test('should show search-icon-reset if contains search text', ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__SearchField_mjs__["default"], {
            searchText: "test text",
            setSearchText: ()=>{}
        }));
        const focusIcon = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.queryByLabelText('search-icon-focus');
        const resetIcon = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.queryByLabelText('search-icon-reset');
        expect(focusIcon).not.toBeInTheDocument();
        expect(resetIcon).toBeInTheDocument();
    });
    test('should focus on input if clicking search icon', ()=>{
        const renderResult = (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__SearchField_mjs__["default"], {
            searchText: "",
            setSearchText: ()=>{}
        }));
        const searchIcon = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.queryByLabelText('search-icon-focus')?.parentElement;
        const searchInput = renderResult.getByPlaceholderText('Search...');
        searchIcon.click();
        const focusedElement = document.activeElement;
        expect(searchInput).toBe(focusedElement);
    });
    test('should call setSearchText with blank string when click search-icon-reset', ()=>{
        const mockSetSearchText = jest.fn();
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__SearchField_mjs__["default"], {
            searchText: "test text",
            setSearchText: mockSetSearchText
        }));
        const exitIcon = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.queryByLabelText('search-icon-reset')?.parentElement;
        exitIcon.click();
        expect(mockSetSearchText).toHaveBeenCalled();
        expect(mockSetSearchText).toHaveBeenCalledWith('');
    });
    test('should call setSearchText with input text', ()=>{
        const mockSetSearchText = jest.fn();
        const renderResult = (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__SearchField_mjs__["default"], {
            searchText: "",
            setSearchText: mockSetSearchText
        }));
        const searchInput = renderResult.getByPlaceholderText('Search...');
        const searchText = 'test text';
        __WEBPACK_EXTERNAL_MODULE__testing_library_react__.fireEvent.change(searchInput, {
            target: {
                value: searchText
            }
        });
        expect(mockSetSearchText).toHaveBeenCalled();
        expect(mockSetSearchText).toHaveBeenCalledWith(searchText);
    });
});
