import { describe, expect, it } from 'vitest' import { physicalWeightKg, physicalWeightLb, totalPhysicalWeightLb } from './dispatchPhysicalWeight' describe('dispatch physical weight', () => { it('keeps absent or invalid physical weight unknown', () => { for (const value of [null, undefined, '', 0, -1, Number.NaN, Number.POSITIVE_INFINITY]) expect(physicalWeightKg(value)).toBeNull() expect(physicalWeightLb(10)).toBeCloseTo(22.046226218) }) it('never substitutes billing volume weight and does not publish partial totals', () => { const unknown = { grossWeightKg: null, volumeWeightKg: 999 } expect(totalPhysicalWeightLb([{ grossWeightKg: 20 }, unknown])).toBeNull() expect(totalPhysicalWeightLb([undefined])).toBeNull() expect(totalPhysicalWeightLb([{ grossWeightKg: 20 }, { grossWeightKg: 30 }])).toBeCloseTo(110.23113109) expect(totalPhysicalWeightLb([])).toBe(0) }) })