// @vitest-environment jsdom
import { describe, it, expect, beforeEach, vi } from 'vitest';
import '@testing-library/jest-dom/vitest';
import { render, screen, cleanup } from '@testing-library/react';

vi.mock('../../src/renderer/inbox/api.js', () => ({
  inboxApi: {} as never,
  notebookApi: {} as never
}));

import { Sidebar } from '../../src/renderer/inbox/components/Sidebar';
import { useInbox } from '../../src/renderer/inbox/store';

describe('Sidebar', () => {
  beforeEach(() => {
    cleanup();
    useInbox.setState({ sidebarVisible: false, sidebarWidth: 240, notebooks: [], selectedNotebookId: null } as never);
  });

  it('sidebarVisible=false 면 렌더링 안 함', () => {
    const { container } = render(<Sidebar />);
    expect(container.firstChild).toBeNull();
  });

  it('sidebarVisible=true 면 NotebookList 렌더링', () => {
    useInbox.setState({
      sidebarVisible: true,
      sidebarWidth: 240,
      notebooks: [{ id: 'nb-1', name: '기본', color: null, createdAt: 't', updatedAt: 't', noteCount: 0 }],
      selectedNotebookId: 'nb-1'
    } as never);
    render(<Sidebar />);
    expect(screen.getByText('기본')).toBeInTheDocument();
  });
});
