import { describe, expect, it } from 'vitest'
import type { SourceFileType } from './types'
import { documentWidget, documentWidgetRegistry, exhibitWidget, exhibitWidgetRegistry } from './exhibitRegistry'

describe('frontend exhibit registry', () => {
  it('registers every normalized exhibit type', () => {
    const types = ['folder', 'document', 'note', 'event', 'party'] as const
    expect(Object.keys(exhibitWidgetRegistry).sort()).toEqual([...types].sort())
    expect(exhibitWidget('event').heading({} as never, { exhibits: [], relations: [], dispatch: () => {} })).toContain('THIS HAPPENED')
  })

  it('registers every normalized document type with an explicit renderer', () => {
    const types: SourceFileType[] = ['image', 'pdf', 'web_capture', 'email', 'article', 'filing', 'price_list', 'text', 'file']
    expect(Object.keys(documentWidgetRegistry).sort()).toEqual(types.sort())
    for (const type of types) {
      expect(documentWidget(type).label).toBeTruthy()
      expect(documentWidget(type).Preview).toBeTypeOf('function')
      expect(documentWidget(type).Asset).toBeTypeOf('function')
    }
  })
})
