import { describe, expect, it } from 'vitest'
import { bilingualPrimary, emptyBilingual } from './BilingualInput'

describe('bilingual field helpers', () => {
  it('returns a stable empty field shape for French and Arabic labels', () => {
    expect(emptyBilingual()).toEqual({ fr: '', ar: '' })
    expect(emptyBilingual()).not.toBe(emptyBilingual())
  })

  it('prefers French as the primary display value when both translations exist', () => {
    expect(bilingualPrimary({ fr: 'Assurance', ar: 'تأمين' })).toBe('Assurance')
  })

  it('falls back to Arabic when the French value is empty', () => {
    expect(bilingualPrimary({ fr: '', ar: 'تأمين' })).toBe('تأمين')
  })

  it('does not trim values implicitly so form state remains lossless', () => {
    expect(bilingualPrimary({ fr: '  Service premium  ', ar: 'خدمة' })).toBe('  Service premium  ')
    expect(bilingualPrimary({ fr: '', ar: '  خدمة  ' })).toBe('  خدمة  ')
  })
})
