import { describe, expect, it } from 'vitest'
import { slugify, slugAlternatives } from '@/lib/domain/slug'

describe('slugify', () => {
  it('lowercases and hyphenates', () => {
    expect(slugify('VA Specialized')).toBe('va-specialized')
  })

  it('removes business suffixes', () => {
    expect(slugify('ABC Logistics LLC')).toBe('abc-logistics')
    expect(slugify('Smith & Sons Transport Inc')).toBe('smith-sons-transport')
  })

  it('strips special characters', () => {
    expect(slugify("O'Brien's Heavy-Haul, Co.")).toBe('obriens-heavy-haul')
  })

  it('collapses and trims hyphens', () => {
    expect(slugify('  --Prime   HeavyHaul--  ')).toBe('prime-heavyhaul')
  })

  it('caps slug length', () => {
    const slug = slugify('a'.repeat(200))
    expect(slug.length).toBeLessThanOrEqual(48)
  })

  it('produces alternatives', () => {
    expect(slugAlternatives('abc')).toEqual(['abc-1', 'abc-2', 'abc-3', 'abc-4', 'abc-5'])
  })
})
