import { render } from '@testing-library/vue';
import { describe, expect, test, beforeEach, afterEach, vi } from 'vitest';
import UiSidebarInset from '../UiSidebarInset.vue';
import {
  createSidebarShell,
  mockMatchMediaDesktop,
} from './sidebar-test-helpers';

beforeEach(() => mockMatchMediaDesktop());
afterEach(() => vi.restoreAllMocks());

describe('UiSidebarInset', () => {
  test('forwards to core SidebarInset with data-sidebar', () => {
    const { container } = render(
      createSidebarShell(
        '<UiSidebarInset data-testid="i">Body</UiSidebarInset>',
        {
          UiSidebarInset,
        },
      ),
    );
    expect(container.querySelector('[data-testid="i"]')).toHaveAttribute(
      'data-slot',
      'sidebar-inset',
    );
    expect(container).toHaveTextContent('Body');
  });

  test('renders inset slot with core data-slot', () => {
    const { container } = render(UiSidebarInset, {
      slots: { default: 'Main' },
    });
    expect(container.querySelector('[data-slot="sidebar-inset"]')).toBeTruthy();
    expect(container).toHaveTextContent('Main');
  });
});
