import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
 * @license
 * Copyright 2025 Vybestack LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { renderAtWidth, testResponsiveBehavior } from './responsive-testing.js';
import { useResponsive } from '../ui/hooks/useResponsive.js';
// Mock the useTerminalSize hook
vi.mock('../ui/hooks/useTerminalSize');
// Test component to verify the responsive testing utilities
function TestComponent() {
    const { breakpoint, width } = useResponsive();
    return (_jsxs("div", { children: [_jsx("span", { "data-testid": "breakpoint", children: breakpoint }), _jsx("span", { "data-testid": "width", children: width })] }));
}
describe('responsive testing utilities', () => {
    beforeEach(() => {
        vi.resetAllMocks();
    });
    describe('renderAtWidth', () => {
        it('should render component with mocked terminal width', () => {
            const result = renderAtWidth(_jsx(TestComponent, {}), 100);
            expect(result.getByTestId('width').textContent).toBe('100');
            expect(result.getByTestId('breakpoint').textContent).toBe('STANDARD');
        });
        it('should render component at narrow width', () => {
            const result = renderAtWidth(_jsx(TestComponent, {}), 60);
            expect(result.getByTestId('width').textContent).toBe('60');
            expect(result.getByTestId('breakpoint').textContent).toBe('NARROW');
        });
        it('should render component at wide width', () => {
            const result = renderAtWidth(_jsx(TestComponent, {}), 200);
            expect(result.getByTestId('width').textContent).toBe('200');
            expect(result.getByTestId('breakpoint').textContent).toBe('WIDE');
        });
    });
    describe('testResponsiveBehavior', () => {
        it('should run assertions for specified breakpoints', () => {
            const narrowAssertionSpy = vi.fn();
            const standardAssertionSpy = vi.fn();
            const wideAssertionSpy = vi.fn();
            testResponsiveBehavior('TestComponent responsive behavior', _jsx(TestComponent, {}), {
                narrow: (result) => {
                    expect(result.getByTestId('breakpoint').textContent).toBe('NARROW');
                    narrowAssertionSpy();
                },
                standard: (result) => {
                    expect(result.getByTestId('breakpoint').textContent).toBe('STANDARD');
                    standardAssertionSpy();
                },
                wide: (result) => {
                    expect(result.getByTestId('breakpoint').textContent).toBe('WIDE');
                    wideAssertionSpy();
                },
            });
            expect(narrowAssertionSpy).toHaveBeenCalledTimes(1);
            expect(standardAssertionSpy).toHaveBeenCalledTimes(1);
            expect(wideAssertionSpy).toHaveBeenCalledTimes(1);
        });
        it('should run only specified assertions', () => {
            const narrowAssertionSpy = vi.fn();
            const wideAssertionSpy = vi.fn();
            testResponsiveBehavior('TestComponent partial responsive behavior', _jsx(TestComponent, {}), {
                narrow: () => narrowAssertionSpy(),
                wide: () => wideAssertionSpy(),
                // Note: no standard assertion
            });
            expect(narrowAssertionSpy).toHaveBeenCalledTimes(1);
            expect(wideAssertionSpy).toHaveBeenCalledTimes(1);
        });
        it('should provide RenderResult with expected methods', () => {
            testResponsiveBehavior('RenderResult validation', _jsx(TestComponent, {}), {
                standard: (result) => {
                    expect(result.getByTestId).toBeDefined();
                    expect(result.queryByTestId).toBeDefined();
                    expect(result.container).toBeDefined();
                    expect(result.unmount).toBeDefined();
                },
            });
        });
        it('should handle empty assertions object', () => {
            expect(() => {
                testResponsiveBehavior('Empty assertions', _jsx(TestComponent, {}), {});
            }).not.toThrow();
        });
    });
});
//# sourceMappingURL=responsive-testing.test.js.map