"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
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 monitor_sampleapp_quickstart_1 = require("./monitor-sampleapp-quickstart");
const QuickStartTileDescription_1 = __importStar(require("./QuickStartTileDescription"));
describe('pluralizeWord function', () => {
    it('should render no plural correctly', () => {
        expect((0, QuickStartTileDescription_1.pluralizeWord)(2, 'pizza')).toBe('pizzas');
    });
});
describe('QuickStart tile description', () => {
    it('should render no prereqs correctly', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(QuickStartTileDescription_1.default, { description: monitor_sampleapp_quickstart_1.monitorSampleAppQuickStart.spec.description }));
        expect(react_1.screen.queryByRole('heading')).toBeFalsy();
    });
    it('should render singular prereq correctly', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(QuickStartTileDescription_1.default, { description: monitor_sampleapp_quickstart_1.monitorSampleAppQuickStart.spec.description, prerequisites: [`You completed the "Getting started with a sample" quick start.`] }));
        expect(react_1.screen.getByRole('heading', { name: /1 Prerequisite/i })).toBeTruthy();
        expect(react_1.screen.getByRole('button', { name: /Show prerequisite/i })).toBeTruthy();
    });
    it('should render plural prereq correctly', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(QuickStartTileDescription_1.default, { description: monitor_sampleapp_quickstart_1.monitorSampleAppQuickStart.spec.description, prerequisites: [
                `You completed the "Getting started with a sample" quick start.`,
                `You completed the app quick start`
            ] }));
        expect(react_1.screen.getByRole('heading', { name: /2 Prerequisites/i })).toBeTruthy();
        expect(react_1.screen.getByRole('button', { name: /Show prerequisites/i })).toBeTruthy();
    });
    it('should be able to click prereqs link', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(QuickStartTileDescription_1.default, { description: monitor_sampleapp_quickstart_1.monitorSampleAppQuickStart.spec.description, prerequisites: [`You completed the "Getting started with a sample" quick start.`] }));
        const button = react_1.screen.getByRole('button', { name: /Show prerequisites/i });
        expect(react_1.screen.queryByRole('dialog', { name: /Prerequisite/i })).toBeFalsy();
        yield user_event_1.default.click(button);
        expect(react_1.screen.getByRole('dialog', { name: /Prerequisite/i })).toBeTruthy();
        expect(react_1.screen.getByRole('button', { name: /Close/i })).toBeTruthy();
        expect(react_1.screen.getByText(/You completed the "Getting started with a sample" quick start./i)).toBeTruthy();
    }));
});
