import * as __WEBPACK_EXTERNAL_MODULE__testing_library_react__ from "@testing-library/react";
import * as __WEBPACK_EXTERNAL_MODULE_copy_to_clipboard__ from "copy-to-clipboard";
import * as __WEBPACK_EXTERNAL_MODULE__CopyButton_mjs__ from "./CopyButton.mjs";
jest.mock('copy-to-clipboard');
describe('CopyButton', ()=>{
    const content = 'brew install rpk';
    test('should render copy button with no labels', ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__CopyButton_mjs__["default"], {
            content: content
        }));
        const copyButton = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByLabelText(/copy/i);
        expect(copyButton).toBeVisible();
    });
    test('should render copy button with labels', ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__CopyButton_mjs__["default"], {
            content: content,
            showLabel: true
        }));
        const copyButton = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByText(/copy/i);
        expect(copyButton).toBeVisible();
    });
    test('should render copy button with custom labels', ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__CopyButton_mjs__["default"], {
            content: content,
            showLabel: true,
            customLabel: "Custom"
        }));
        const copyButton = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByText(/custom/i);
        expect(copyButton).toBeVisible();
    });
    test('should copy content to clipboard on click', ()=>{
        __WEBPACK_EXTERNAL_MODULE_copy_to_clipboard__["default"].mockReturnValue(true);
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__CopyButton_mjs__["default"], {
            content: content
        }));
        const copyButton = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByLabelText(/copy/i);
        expect(__WEBPACK_EXTERNAL_MODULE_copy_to_clipboard__["default"]).not.toHaveBeenCalled();
        __WEBPACK_EXTERNAL_MODULE__testing_library_react__.fireEvent.click(copyButton);
        expect(__WEBPACK_EXTERNAL_MODULE_copy_to_clipboard__["default"]).toHaveBeenCalledTimes(1);
        expect(__WEBPACK_EXTERNAL_MODULE_copy_to_clipboard__["default"]).toHaveBeenCalledWith(content, {});
    });
    test('should change label on copy', ()=>{
        __WEBPACK_EXTERNAL_MODULE_copy_to_clipboard__["default"].mockReturnValue(true);
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__CopyButton_mjs__["default"], {
            content: content
        }));
        const copyButton = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByLabelText(/copy/i);
        expect(copyButton).toBeVisible();
        __WEBPACK_EXTERNAL_MODULE__testing_library_react__.fireEvent.click(copyButton);
        const copyButtonTextChange = __WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByLabelText(/copied/i);
        expect(copyButtonTextChange).toBeVisible();
    });
    test('should allow triggering custom onClick events', ()=>{
        const mockOnClick = jest.fn();
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__CopyButton_mjs__["default"], {
            content: content,
            onClick: mockOnClick
        }));
        __WEBPACK_EXTERNAL_MODULE__testing_library_react__.fireEvent.click(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByLabelText(/copy/i));
        expect(mockOnClick).toHaveBeenCalledTimes(1);
    });
});
