import { describe, it, expect } from 'vitest'
import { isPhoneUA } from '@/lib/user-agent'

describe('isPhoneUA', () => {
  it('iPhone Safari Mobile → true', () => {
    const ua = 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Mobile/15E148 Safari/604.1'
    expect(isPhoneUA(ua)).toBe(true)
  })

  it('Android Chrome (phone) → true', () => {
    const ua = 'Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Mobile Safari/537.36'
    expect(isPhoneUA(ua)).toBe(true)
  })

  it('iPad → false (geen Mobi)', () => {
    const ua = 'Mozilla/5.0 (iPad; CPU OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/604.1'
    expect(isPhoneUA(ua)).toBe(false)
  })

  it('Android tablet (Galaxy Tab) → false', () => {
    const ua = 'Mozilla/5.0 (Linux; Android 14; SM-X910) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36'
    expect(isPhoneUA(ua)).toBe(false)
  })

  it('Desktop Chrome → false', () => {
    const ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36'
    expect(isPhoneUA(ua)).toBe(false)
  })

  it('null → false', () => {
    expect(isPhoneUA(null)).toBe(false)
  })

  it('lege string → false', () => {
    expect(isPhoneUA('')).toBe(false)
  })
})
