import { render } from '@testing-library/vue';
import { describe, expect, test, beforeEach, afterEach, vi } from 'vitest';
import {
  Popover,
  PopoverContent,
  PopoverTrigger,
} from '@/components/core/popover';
import UiSidebarPopoverTrigger from '../UiSidebarPopoverTrigger.vue';
import {
  createSidebarShell,
  mockMatchMediaDesktop,
} from './sidebar-test-helpers';

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

describe('UiSidebarPopoverTrigger', () => {
  test('renders label in sidebar menu button', () => {
    const { getByText } = render(
      createSidebarShell(
        `
        <Popover>
          <PopoverTrigger as-child>
            <UiSidebarPopoverTrigger label="Acme Inc" tooltip="Switch" />
          </PopoverTrigger>
          <PopoverContent>Panel</PopoverContent>
        </Popover>
      `,
        {
          Popover,
          PopoverTrigger,
          PopoverContent,
          UiSidebarPopoverTrigger,
        },
      ),
    );
    expect(getByText('Acme Inc')).toBeInTheDocument();
  });
});
