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 Onboarding from './Onboarding';
const handleModalToggle = jest.fn();
const onPrimaryAction = jest.fn();
const onSecondaryAction = jest.fn();
const body = 'Experience personalized assistance and seamless problem-solving, simplifying your journey with Red Hat every step of the way.';
describe('Onboarding', () => {
    afterEach(() => {
        jest.clearAllMocks();
    });
    it('should render modal correctly', () => {
        render(_jsx(Onboarding, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, ouiaId: "Terms", children: body }));
        expect(screen.getByRole('heading', { name: /Onboarding/i })).toBeTruthy();
        expect(screen.getByRole('button', { name: /Continue/i })).toBeTruthy();
        expect(screen.getByRole('button', { name: /Skip/i })).toBeTruthy();
        expect(screen.getByText(body)).toBeTruthy();
        expect(screen.getByRole('dialog')).toHaveClass('pf-chatbot__onboarding-modal');
        expect(screen.getByRole('dialog')).toHaveClass('pf-chatbot__onboarding-modal--default');
    });
    it('should handle image and altText props', () => {
        render(_jsx(Onboarding, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, headerImage: "./image.png", headerImageAltText: "Test image", children: body }));
        expect(screen.getByRole('img')).toBeTruthy();
        expect(screen.getByRole('img')).toHaveAttribute('alt', 'Test image');
    });
    it('should handle className prop', () => {
        render(_jsx(Onboarding, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, className: "test", children: body }));
        expect(screen.getByRole('dialog')).toHaveClass('pf-chatbot__onboarding-modal');
        expect(screen.getByRole('dialog')).toHaveClass('pf-chatbot__onboarding-modal--default');
        expect(screen.getByRole('dialog')).toHaveClass('test');
    });
    it('should handle title prop', () => {
        render(_jsx(Onboarding, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, title: "Updated title", children: body }));
        expect(screen.getByRole('heading', { name: /Updated title/i })).toBeTruthy();
        expect(screen.queryByRole('heading', { name: /Onboarding/i })).toBeFalsy();
    });
    it('should handle primary button prop', () => {
        render(_jsx(Onboarding, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, primaryActionBtn: "First", children: body }));
        expect(screen.getByRole('button', { name: /First/i })).toBeTruthy();
        expect(screen.queryByRole('button', { name: /Continue/i })).toBeFalsy();
    });
    it('should handle secondary button prop', () => {
        render(_jsx(Onboarding, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, secondaryActionBtn: "Second", children: body }));
        expect(screen.getByRole('button', { name: /Second/i })).toBeTruthy();
        expect(screen.queryByRole('button', { name: /Skip/i })).toBeFalsy();
    });
    it('should handle primary button click', () => __awaiter(void 0, void 0, void 0, function* () {
        render(_jsx(Onboarding, { isModalOpen: true, onPrimaryAction: onPrimaryAction, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, children: body }));
        yield userEvent.click(screen.getByRole('button', { name: /Continue/i }));
        expect(onPrimaryAction).toHaveBeenCalledTimes(1);
        expect(handleModalToggle).toHaveBeenCalledTimes(1);
    }));
    it('should handle secondary button click', () => __awaiter(void 0, void 0, void 0, function* () {
        render(_jsx(Onboarding, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, children: body }));
        yield userEvent.click(screen.getByRole('button', { name: /Skip/i }));
        expect(onSecondaryAction).toHaveBeenCalledTimes(1);
        expect(handleModalToggle).not.toHaveBeenCalled();
    }));
    it('should handle isCompact prop', () => {
        render(_jsx(Onboarding, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, isCompact: true, headerImage: "./image.png", headerImageAltText: "Test image", children: body }));
        expect(screen.getByRole('dialog')).toHaveClass('pf-m-compact');
        expect(screen.queryByRole('img')).toBeFalsy();
    });
});
