import React from 'react';
import { render, screen } from '@testing-library/react';
import { WgerModal, WgerModalProps } from "@/core/ui/Modals/WgerModal";

describe("Test WgerModal component", () => {
    test('Renders title and subtitle when openFn is true', () => {

        // Arrange
        const props: Omit<WgerModalProps, 'children'> = {
            title: "Test title",
            subtitle: "Test subtitle",
            closeFn: vi.fn(),
            isOpen: true,
        };

        // Act
        render(<WgerModal {...props} ><p>This is some content</p></WgerModal>);

        // Assert
        expect(screen.getByText('This is some content')).toBeInTheDocument();
        expect(screen.getByText('Test title')).toBeInTheDocument();
        expect(screen.getByText('Test subtitle')).toBeInTheDocument();
    });

    test('Doesnt render anything when isOpen is false', () => {

        // Arrange
        const props: Omit<WgerModalProps, 'children'> = {
            title: "Test title",
            subtitle: "Test subtitle",
            closeFn: vi.fn(),
            isOpen: false,
        };

        // Act
        render(<WgerModal {...props} ><p>This is some content</p></WgerModal>);

        // Assert
        expect(screen.queryByText('This is some content')).toBeNull();
        expect(screen.queryByText('Test title')).toBeNull();
        expect(screen.queryByText('Test subtitle')).toBeNull();
    });
});
