import { describe, it, expect, vi } from 'vitest';
import ReferenceDetail from './page';

// Mock next/navigation
vi.mock('next/navigation', () => ({
  notFound: vi.fn(),
}));

// Mock next-intl/server
vi.mock('next-intl/server', () => ({
  setRequestLocale: vi.fn(),
  getTranslations: vi.fn().mockResolvedValue(() => 'translated text'),
}));

// Mock @/lib/references
vi.mock('@/lib/references', () => ({
  getReferenceBySlug: vi.fn().mockResolvedValue({
    slug: 'test-slug',
    frontmatter: {
      title: 'Test Title',
      location: 'Test Location',
      category: 'Test Category',
    },
    content: 'Test content',
  }),
}));

describe('ReferenceDetail Page TDD', () => {
  it('renders reference detail correctly', async () => {
    const props = {
      params: Promise.resolve({ locale: 'de', slug: 'test-slug' })
    };
    
    // We expect the execution to fail if getTranslations is not defined/imported inside page.tsx
    const component = await ReferenceDetail(props);
    expect(component).toBeTruthy();
  });
});
