"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 JumpButton_1 = __importDefault(require("./JumpButton"));
const user_event_1 = __importDefault(require("@testing-library/user-event"));
describe('JumpButton', () => {
    it('should render top button correctly', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(JumpButton_1.default, { position: "top", onClick: jest.fn() }));
        expect(react_1.screen.getByRole('button', { name: /Back to top/i })).toBeTruthy();
    });
    it('should render bottom button correctly', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(JumpButton_1.default, { position: "bottom", onClick: jest.fn() }));
        expect(react_1.screen.getByRole('button', { name: /Back to bottom/i })).toBeTruthy();
    });
    it('should call onClick appropriately', () => __awaiter(void 0, void 0, void 0, function* () {
        const spy = jest.fn();
        (0, react_1.render)((0, jsx_runtime_1.jsx)(JumpButton_1.default, { position: "bottom", onClick: spy }));
        yield user_event_1.default.click(react_1.screen.getByRole('button', { name: /Back to bottom/i }));
        expect(spy).toHaveBeenCalledTimes(1);
    }));
    it('should be hidden if isHidden prop is used', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(JumpButton_1.default, { position: "bottom", onClick: jest.fn(), isHidden: true }));
        expect(react_1.screen.queryByRole('button', { name: /Back to bottom/i })).toBeFalsy();
    }));
});
