import test from 'node:test';import assert from 'node:assert/strict';import {customerHistorySeries} from '../src/customerHistory.mjs'; test('empty and all-zero periods have finite chart coordinates',()=>{for(const rows of [[],[{month:'2026-01',amount:0,orders:0}]]){const s=customerHistorySeries(rows,'amount');assert.equal(s.zero,170);assert.ok(s.points.every(p=>Number.isFinite(p.x)&&Number.isFinite(p.y)));}}); test('credits plot below zero and amounts are not clamped',()=>{const s=customerHistorySeries([{month:'2025-12',amount:-50,orders:1},{month:'2026-01',amount:100,orders:2}],'amount');assert.deepEqual(s.points.map(p=>p.value),[-50,100]);assert.ok(s.points[0].y>s.zero&&s.points[1].yp.x),[40,700]);}); test('order counts use their own scale and invalid values are rejected',()=>{const s=customerHistorySeries([{month:'2026-01',amount:10000,orders:3}],'orders');assert.equal(s.max,3);assert.equal(s.points[0].y,25);assert.throws(()=>customerHistorySeries([{month:'x',amount:NaN,orders:1}],'amount'),/Monatswert/);});