var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
import { jsx as _jsx } from "react/jsx-runtime";
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import userEvent from '@testing-library/user-event';
import { StopButton } from './StopButton';
const renderStop = (props) => {
    const spy = jest.fn();
    render(_jsx(StopButton, Object.assign({ onClick: spy }, props)));
};
describe('Stop button', () => {
    it('should render button correctly', () => {
        renderStop();
        expect(screen.getByRole('button', { name: 'Stop' })).toBeTruthy();
    });
    it('should handle onClick correctly', () => __awaiter(void 0, void 0, void 0, function* () {
        const spy = jest.fn();
        render(_jsx(StopButton, { onClick: spy }));
        yield userEvent.click(screen.getByRole('button', { name: 'Stop' }));
        expect(screen.getByRole('tooltip', { name: 'Stop' })).toBeTruthy();
        expect(spy).toHaveBeenCalledTimes(1);
    }));
    it('should handle custom tooltip correctly', () => __awaiter(void 0, void 0, void 0, function* () {
        render(_jsx(StopButton, { onClick: jest.fn, tooltipContent: "Test" }));
        yield userEvent.click(screen.getByRole('button', { name: 'Stop' }));
        expect(screen.getByRole('tooltip', { name: 'Test' })).toBeTruthy();
    }));
    it('should handle className prop', () => {
        renderStop({ className: 'test' });
        expect(screen.getByRole('button', { name: 'Stop' })).toHaveClass('test');
    });
    it('should handle spread props, including aria-label', () => {
        renderStop({ 'aria-label': 'test' });
        expect(screen.getByRole('button', { name: 'test' }));
    });
    it('should handle tooltipProps prop', () => __awaiter(void 0, void 0, void 0, function* () {
        renderStop({ tooltipProps: { id: 'test' } });
        yield userEvent.click(screen.getByRole('button', { name: 'Stop' }));
        expect(screen.getByRole('tooltip', { name: 'Stop' })).toHaveAttribute('id', 'test');
    }));
    it('should handle isCompact', () => {
        renderStop({ 'data-testid': 'button', isCompact: true });
        expect(screen.getByTestId('button')).toHaveClass('pf-m-compact');
    });
});
