import assert from 'node:assert/strict'; import test from 'node:test'; import { formatCount, formatDateTime, formatDecimal, formatFixed, summarizeOverall, } from './model'; test('summarizeOverall preserves aggregate totals and per-kind values', () => { assert.deepEqual(summarizeOverall([ { vehicle_kind: 'internal', records: 3, total_kwh: 12.34, total_fee: 20.5 }, { vehicle_kind: 'external', records: 2, total_kwh: 5.66, total_fee: 9.5 }, ]), { totalRecords: 5, totalKwh: 18, totalFee: 30, internalRecords: 3, externalRecords: 2, internalKwh: 12.34, externalKwh: 5.66, }); }); test('summarizeOverall preserves empty fallbacks', () => { assert.deepEqual(summarizeOverall([]), { totalRecords: 0, totalKwh: 0, totalFee: 0, internalRecords: 0, externalRecords: 0, internalKwh: 0, externalKwh: 0, }); }); test('formatters preserve the import page display rules', () => { assert.equal(formatDateTime('2026-08-13T09:08:07.000Z', 19), '2026-08-13 09:08:07'); assert.equal(formatDateTime(null, 16), ''); assert.equal(formatCount(1234), (1234).toLocaleString()); assert.equal(formatDecimal(1234.56, 1), (1234.56).toLocaleString('zh-CN', { maximumFractionDigits: 1 })); assert.equal(formatFixed(null, 2), '0.00'); });