File size: 670 Bytes
386cc29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import test from 'node:test';
import assert from 'node:assert/strict';
import { buildChartSummaryText, createProfitChartPng } from '../src/chart.js';

test('creates a png buffer for mixed chart points', async () => {
  const buffer = await createProfitChartPng([
    { label: '#1', runningProfit: -25 },
    { label: '#2', runningProfit: 10 },
    { label: '#3', runningProfit: 42.5 },
  ]);

  assert.ok(Buffer.isBuffer(buffer));
  assert.ok(buffer.length > 1000);
  assert.equal(buffer.subarray(0, 8).toString('hex'), '89504e470d0a1a0a');
});

test('builds an empty-state chart summary', () => {
  assert.match(buildChartSummaryText([]), /No resolved bets yet/i);
});