import { describe, expect, it } from 'vitest'
import { useExportFields } from '../useExportFields'

describe('useExportFields', () => {
  it('keeps required fields selected', () => {
    const { selected, toggle } = useExportFields(
      [
        { key: 'name', label: 'Name', required: true },
        { key: 'status', label: 'Status' }
      ],
      ['status']
    )

    expect(selected.value).toEqual(['name', 'status'])

    toggle('name', false)
    expect(selected.value).toEqual(['name', 'status'])
  })

  it('can clear optional fields', () => {
    const { selected, clearOptional } = useExportFields(
      [
        { key: 'name', label: 'Name', required: true },
        { key: 'status', label: 'Status' }
      ],
      ['name', 'status']
    )

    clearOptional()
    expect(selected.value).toEqual(['name'])
  })
})
