"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 Onboarding_1 = __importDefault(require("./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', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(Onboarding_1.default, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, ouiaId: "Terms", children: body }));
        expect(react_1.screen.getByRole('heading', { name: /Onboarding/i })).toBeTruthy();
        expect(react_1.screen.getByRole('button', { name: /Continue/i })).toBeTruthy();
        expect(react_1.screen.getByRole('button', { name: /Skip/i })).toBeTruthy();
        expect(react_1.screen.getByText(body)).toBeTruthy();
        expect(react_1.screen.getByRole('dialog')).toHaveClass('pf-chatbot__onboarding-modal');
        expect(react_1.screen.getByRole('dialog')).toHaveClass('pf-chatbot__onboarding-modal--default');
    });
    it('should handle image and altText props', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(Onboarding_1.default, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, headerImage: "./image.png", headerImageAltText: "Test image", children: body }));
        expect(react_1.screen.getByRole('img')).toBeTruthy();
        expect(react_1.screen.getByRole('img')).toHaveAttribute('alt', 'Test image');
    });
    it('should handle className prop', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(Onboarding_1.default, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, className: "test", children: body }));
        expect(react_1.screen.getByRole('dialog')).toHaveClass('pf-chatbot__onboarding-modal');
        expect(react_1.screen.getByRole('dialog')).toHaveClass('pf-chatbot__onboarding-modal--default');
        expect(react_1.screen.getByRole('dialog')).toHaveClass('test');
    });
    it('should handle title prop', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(Onboarding_1.default, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, title: "Updated title", children: body }));
        expect(react_1.screen.getByRole('heading', { name: /Updated title/i })).toBeTruthy();
        expect(react_1.screen.queryByRole('heading', { name: /Onboarding/i })).toBeFalsy();
    });
    it('should handle primary button prop', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(Onboarding_1.default, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, primaryActionBtn: "First", children: body }));
        expect(react_1.screen.getByRole('button', { name: /First/i })).toBeTruthy();
        expect(react_1.screen.queryByRole('button', { name: /Continue/i })).toBeFalsy();
    });
    it('should handle secondary button prop', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(Onboarding_1.default, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, secondaryActionBtn: "Second", children: body }));
        expect(react_1.screen.getByRole('button', { name: /Second/i })).toBeTruthy();
        expect(react_1.screen.queryByRole('button', { name: /Skip/i })).toBeFalsy();
    });
    it('should handle primary button click', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(Onboarding_1.default, { isModalOpen: true, onPrimaryAction: onPrimaryAction, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, children: body }));
        yield user_event_1.default.click(react_1.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* () {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(Onboarding_1.default, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, children: body }));
        yield user_event_1.default.click(react_1.screen.getByRole('button', { name: /Skip/i }));
        expect(onSecondaryAction).toHaveBeenCalledTimes(1);
        expect(handleModalToggle).not.toHaveBeenCalled();
    }));
    it('should handle isCompact prop', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(Onboarding_1.default, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, isCompact: true, headerImage: "./image.png", headerImageAltText: "Test image", children: body }));
        expect(react_1.screen.getByRole('dialog')).toHaveClass('pf-m-compact');
        expect(react_1.screen.queryByRole('img')).toBeFalsy();
    });
});
