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 { monitorSampleAppQuickStart } from './monitor-sampleapp-quickstart';
import QuickStartTileDescription, { pluralizeWord } from './QuickStartTileDescription';
describe('pluralizeWord function', () => {
    it('should render no plural correctly', () => {
        expect(pluralizeWord(2, 'pizza')).toBe('pizzas');
    });
});
describe('QuickStart tile description', () => {
    it('should render no prereqs correctly', () => {
        render(_jsx(QuickStartTileDescription, { description: monitorSampleAppQuickStart.spec.description }));
        expect(screen.queryByRole('heading')).toBeFalsy();
    });
    it('should render singular prereq correctly', () => {
        render(_jsx(QuickStartTileDescription, { description: monitorSampleAppQuickStart.spec.description, prerequisites: [`You completed the "Getting started with a sample" quick start.`] }));
        expect(screen.getByRole('heading', { name: /1 Prerequisite/i })).toBeTruthy();
        expect(screen.getByRole('button', { name: /Show prerequisite/i })).toBeTruthy();
    });
    it('should render plural prereq correctly', () => {
        render(_jsx(QuickStartTileDescription, { description: monitorSampleAppQuickStart.spec.description, prerequisites: [
                `You completed the "Getting started with a sample" quick start.`,
                `You completed the app quick start`
            ] }));
        expect(screen.getByRole('heading', { name: /2 Prerequisites/i })).toBeTruthy();
        expect(screen.getByRole('button', { name: /Show prerequisites/i })).toBeTruthy();
    });
    it('should be able to click prereqs link', () => __awaiter(void 0, void 0, void 0, function* () {
        render(_jsx(QuickStartTileDescription, { description: monitorSampleAppQuickStart.spec.description, prerequisites: [`You completed the "Getting started with a sample" quick start.`] }));
        const button = screen.getByRole('button', { name: /Show prerequisites/i });
        expect(screen.queryByRole('dialog', { name: /Prerequisite/i })).toBeFalsy();
        yield userEvent.click(button);
        expect(screen.getByRole('dialog', { name: /Prerequisite/i })).toBeTruthy();
        expect(screen.getByRole('button', { name: /Close/i })).toBeTruthy();
        expect(screen.getByText(/You completed the "Getting started with a sample" quick start./i)).toBeTruthy();
    }));
});
