import { render, screen } from '@testing-library/react';
import { TabLink } from '@/components/TabLink';
import Layout from './layout';

vi.mock('@/i18n/server', () => ({
    getScopedI18n: vi.fn().mockReturnValue((term: string) => term),
}));

vi.mock('@/components/TabLink', () => ({
    TabLink: vi.fn(() => <a>TabLink</a>),
}));

describe('<Layout>', () => {
    describe('navigation tabs', () => {
        it('should render "Profile" tab', async () => {
            render(await Layout({ children: <div>Page</div> }));

            expect(TabLink).toHaveBeenCalledWith(
                expect.objectContaining({
                    href: 'settings',
                    children: 'tabs.profile',
                }),
                undefined
            );
        });

        it('should render "Subscriptions" tab', async () => {
            render(await Layout({ children: <div>Page</div> }));

            expect(TabLink).toHaveBeenCalledWith(
                expect.objectContaining({
                    href: 'subscriptions',
                    children: 'tabs.subscriptions',
                }),
                undefined
            );
        });
    });

    it('should render children', async () => {
        render(await Layout({ children: <div>Page</div> }));

        expect(screen.getByText('Page')).toBeInTheDocument();
    });
});
