"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 react_1 = __importDefault(require("react"));
const react_2 = require("@testing-library/react");
require("@testing-library/jest-dom");
const user_event_1 = __importDefault(require("@testing-library/user-event"));
const SendButton_1 = require("./SendButton");
const renderSend = (props) => {
    const spy = jest.fn();
    (0, react_2.render)(react_1.default.createElement(SendButton_1.SendButton, Object.assign({ onClick: spy }, props)));
};
describe('Send button', () => {
    it('should render button correctly', () => {
        renderSend();
        expect(react_2.screen.getByRole('button', { name: 'Send' })).toBeTruthy();
    });
    it('should handle onClick correctly', () => __awaiter(void 0, void 0, void 0, function* () {
        const spy = jest.fn();
        (0, react_2.render)(react_1.default.createElement(SendButton_1.SendButton, { onClick: spy }));
        yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Send' }));
        expect(react_2.screen.getByRole('tooltip', { name: 'Send' })).toBeTruthy();
        expect(spy).toHaveBeenCalledTimes(1);
    }));
    it('should handle custom tooltip correctly', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_2.render)(react_1.default.createElement(SendButton_1.SendButton, { onClick: jest.fn, tooltipContent: "Test" }));
        yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Send' }));
        expect(react_2.screen.getByRole('tooltip', { name: 'Test' })).toBeTruthy();
    }));
    it('should handle className prop', () => {
        renderSend({ className: 'test' });
        expect(react_2.screen.getByRole('button', { name: 'Send' })).toHaveClass('test');
    });
    it('should handle spread props, including aria-label', () => {
        renderSend({ 'aria-label': 'test' });
        expect(react_2.screen.getByRole('button', { name: 'test' }));
    });
    it('should handle tooltipProps prop', () => __awaiter(void 0, void 0, void 0, function* () {
        renderSend({ tooltipProps: { id: 'test' } });
        yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Send' }));
        expect(react_2.screen.getByRole('tooltip', { name: 'Send' })).toHaveAttribute('id', 'test');
    }));
    it('should handle isCompact', () => {
        renderSend({ 'data-testid': 'button', isCompact: true });
        expect(react_2.screen.getByTestId('button')).toHaveClass('pf-m-compact');
    });
});
