import { expect, test } from 'bun:test'; import { parseCandlestickResponse } from './cryptocom'; test('parst Crypto.com-Candlestick-Response', () => { const json = { result: { data: [ { t: 900000, o: '1.0', h: '1.2', l: '0.9', c: '1.1', v: '1000' }, { t: 1800000, o: '1.1', h: '1.3', l: '1.0', c: '1.2', v: '500' }, ], }, }; const out = parseCandlestickResponse(json); expect(out).toHaveLength(2); expect(out[0]).toEqual({ ts: 900000, open: 1, high: 1.2, low: 0.9, close: 1.1, volume: 1000 }); }); test('leere/fehlende Daten → leeres Array', () => { expect(parseCandlestickResponse({})).toEqual([]); expect(parseCandlestickResponse({ result: {} })).toEqual([]); });