import { describe, it, expect } from 'vitest'
import { render } from '@testing-library/react'
import { KnowledgeUnitCard } from './KnowledgeUnitCard'
import type { KnowledgeUnit } from '@/lib/sdk/advisor/evidence'
describe('KnowledgeUnitCard', () => {
it('shows the friendly regulation name (not the raw code) when standalone', () => {
const unit: KnowledgeUnit = { id: 's1', regulation: { code: 'cra', short: 'CRA' } }
const { container } = render()
expect(container.textContent).toContain('Cyber Resilience Act (CRA)')
})
it('renders the section/paragraph breadcrumb', () => {
const unit: KnowledgeUnit = {
id: 's2',
regulation: { code: 'dsgvo', short: 'DSGVO' },
section: 'Art. 5',
paragraph: 'Abs. 2',
}
const { container } = render()
expect(container.textContent).toContain('Art. 5')
expect(container.textContent).toContain('Abs. 2')
})
it('compact mode shows the chapter and omits the family name (group provides it)', () => {
const unit: KnowledgeUnit = { id: 's3', regulation: { code: 'dsk_sdm_b51', short: 'DSK Sdm B51' } }
const { container } = render()
expect(container.textContent).toContain('Kapitel B51')
expect(container.textContent).not.toContain('Standard-Datenschutzmodell')
})
})