import { describe, it, expect } from 'vitest'
import { mount } from '@vue/test-utils'
import VerificationFieldCard from '@/components/VerificationFieldCard.vue'

describe('VerificationFieldCard', () => {
  it('renders soft label, bold value, and OK chip', () => {
    const wrapper = mount(VerificationFieldCard, {
      props: {
        label: 'Full Name',
        value: 'Jane Doe',
        checked: false,
      },
    })

    expect(wrapper.text()).toContain('Full Name')
    expect(wrapper.text()).toContain('Jane Doe')
    expect(wrapper.text()).toContain('OK')
    expect(wrapper.find('input[type="checkbox"]').exists()).toBe(true)
  })

  it('shows (empty) when value is blank', () => {
    const wrapper = mount(VerificationFieldCard, {
      props: {
        label: 'MRN',
        value: '',
        checked: false,
      },
    })
    expect(wrapper.text()).toContain('(empty)')
  })

  it('emits toggle when OK checkbox changes', async () => {
    const wrapper = mount(VerificationFieldCard, {
      props: {
        label: 'Sex',
        value: 'F',
        checked: false,
      },
    })

    await wrapper.find('input[type="checkbox"]').setValue(true)
    expect(wrapper.emitted('toggle')?.[0]).toEqual([true])
  })
})
