"use strict";
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());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("@testing-library/react");
require("@testing-library/jest-dom");
const user_event_1 = __importDefault(require("@testing-library/user-event"));
const StopButton_1 = require("./StopButton");
const renderStop = (props) => {
    const spy = jest.fn();
    (0, react_1.render)((0, jsx_runtime_1.jsx)(StopButton_1.StopButton, Object.assign({ onClick: spy }, props)));
};
describe('Stop button', () => {
    it('should render button correctly', () => {
        renderStop();
        expect(react_1.screen.getByRole('button', { name: 'Stop' })).toBeTruthy();
    });
    it('should handle onClick correctly', () => __awaiter(void 0, void 0, void 0, function* () {
        const spy = jest.fn();
        (0, react_1.render)((0, jsx_runtime_1.jsx)(StopButton_1.StopButton, { onClick: spy }));
        yield user_event_1.default.click(react_1.screen.getByRole('button', { name: 'Stop' }));
        expect(react_1.screen.getByRole('tooltip', { name: 'Stop' })).toBeTruthy();
        expect(spy).toHaveBeenCalledTimes(1);
    }));
    it('should handle custom tooltip correctly', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(StopButton_1.StopButton, { onClick: jest.fn, tooltipContent: "Test" }));
        yield user_event_1.default.click(react_1.screen.getByRole('button', { name: 'Stop' }));
        expect(react_1.screen.getByRole('tooltip', { name: 'Test' })).toBeTruthy();
    }));
    it('should handle className prop', () => {
        renderStop({ className: 'test' });
        expect(react_1.screen.getByRole('button', { name: 'Stop' })).toHaveClass('test');
    });
    it('should handle spread props, including aria-label', () => {
        renderStop({ 'aria-label': 'test' });
        expect(react_1.screen.getByRole('button', { name: 'test' }));
    });
    it('should handle tooltipProps prop', () => __awaiter(void 0, void 0, void 0, function* () {
        renderStop({ tooltipProps: { id: 'test' } });
        yield user_event_1.default.click(react_1.screen.getByRole('button', { name: 'Stop' }));
        expect(react_1.screen.getByRole('tooltip', { name: 'Stop' })).toHaveAttribute('id', 'test');
    }));
    it('should handle isCompact', () => {
        renderStop({ 'data-testid': 'button', isCompact: true });
        expect(react_1.screen.getByTestId('button')).toHaveClass('pf-m-compact');
    });
});
