import { expect, test } from 'vitest';
import { buildCsv } from './csvExport';

test('builds csv with escaping and json object values', () => {
  const csv = buildCsv(
    [
      { title: 'VIN', value: (row: { vin: string; fields?: unknown }) => row.vin },
      { title: '字段', value: (row) => row.fields }
    ],
    [{ vin: 'VIN"001', fields: { speed: 42 } }]
  );

  expect(csv).toBe('"VIN","字段"\n"VIN""001","{""speed"":42}"');
});
