import assert from 'node:assert/strict';
import { test } from 'node:test';
import { decideRefund } from '../src/decide.ts';

test('T-4207: a POL-DMG-14 request inside its window is capped at the policy limit', () => {
  const decision = decideRefund(
    {
      id: 'T-4207',
      orderId: 'ORD-8842',
      policyId: 'POL-DMG-14',
      requestedAt: '2026-10-19T16:20:00Z',
      requestedCents: 9500,
      summary: 'Camp stove arrived with a cracked burner.',
    },
    { id: 'ORD-8842', deliveredAt: '2026-10-08T14:00:00Z', priorRefundedCents: 0 },
  );
  assert.equal(decision.policyId, 'POL-DMG-14');
  assert.equal(decision.eligible, true);
  assert.equal(decision.refundCents, 9000);
});
