// A10 Process Cycle Efficiency (§8.6) — hand-calculated tests.
// FIXTURE-DATEN-REGEL: every number below is FREE INVENTION.

import { describe, expect, it } from 'vitest'
import { computePce } from '../internal/pce'

describe('computePce', () => {
  it('hand calc: 40s VA of 100s total lead time -> 40%', () => {
    expect(computePce(40, 100).pcePct).toBe(40)
  })

  it('hand calc: 0s VA of 100s total -> 0% (a real, computable zero)', () => {
    expect(computePce(0, 100).pcePct).toBe(0)
  })

  it('hand calc: fractional result stays unrounded (rounding is a display concern)', () => {
    // 1/3 * 100 = 33.333...
    expect(computePce(1, 3).pcePct).toBeCloseTo(33.3333, 3)
  })

  it('returns null (never Infinity/NaN) when total lead time is 0', () => {
    expect(computePce(0, 0).pcePct).toBeNull()
  })

  it('returns null when either value is missing', () => {
    expect(computePce(undefined, 100).pcePct).toBeNull()
    expect(computePce(40, undefined).pcePct).toBeNull()
    expect(computePce(null, null).pcePct).toBeNull()
  })
})
