import { describe, it, expect } from 'vitest'
import { mount } from '@vue/test-utils'
import Icon from '../src/canonical/Icon.vue'

// P1-1 (owner 2026-07-24): promote the internal registry renderer to a first-class
// public canonical Icon with a default size (16px, override via `size`). Closes the
// "no public Icon in bundle" gap and the "inline oversized SVG" gap (consumers use
// <Icon> instead of hand-inlining raw SVGs).
describe('canonical Icon (P1-1 public export + default size)', () => {
  it('renders a registry icon as inline svg', () => {
    const w = mount(Icon, { props: { name: 'time/clock' } })
    expect(w.html()).toContain('<svg')
  })

  it('applies the default 16px box when size is omitted', () => {
    const w = mount(Icon, { props: { name: 'time/clock' } })
    const style = w.find('.icon').attributes('style') ?? ''
    expect(style).toContain('width: 16px')
    expect(style).toContain('height: 16px')
  })

  it('forwards an explicit size', () => {
    const w = mount(Icon, { props: { name: 'time/clock', size: 32 } })
    const style = w.find('.icon').attributes('style') ?? ''
    expect(style).toContain('width: 32px')
    expect(style).toContain('height: 32px')
  })

  it('forwards aria-hidden via attribute fall-through', () => {
    const w = mount(Icon, { props: { name: 'time/clock' }, attrs: { 'aria-hidden': 'true' } })
    expect(w.find('.icon').attributes('aria-hidden')).toBe('true')
  })
})
