import { describe, expect, it } from 'vitest'
import { WIZARD_FILE_LIMIT_BYTES, fileTooLargeMessage, fileWithinWizardLimit } from '@/lib/domain/upload-limits'

describe('wizard per-file limit (W4, 2026-10-01)', () => {
  it('is 1 MB', () => {
    expect(WIZARD_FILE_LIMIT_BYTES).toBe(1_048_576)
  })
  it('accepts up to the limit and refuses empty or larger files', () => {
    expect(fileWithinWizardLimit(1)).toBe(true)
    expect(fileWithinWizardLimit(1_048_576)).toBe(true)
    expect(fileWithinWizardLimit(1_048_577)).toBe(false)
    expect(fileWithinWizardLimit(0)).toBe(false)
  })
  it('names the file and its size in the message', () => {
    expect(fileTooLargeMessage('scan.pdf', 2.4 * 1024 * 1024)).toBe('scan.pdf is 2.4 MB — files must be 1 MB or smaller.')
    expect(fileTooLargeMessage('big.pdf', 13 * 1024 * 1024)).toBe('big.pdf is 13 MB — files must be 1 MB or smaller.')
  })
})
