2023-10-24 17:21:39 +00:00
|
|
|
import { describe, it, expect } from 'vitest';
|
2024-07-05 12:34:17 +00:00
|
|
|
import { formatObjectForTable } from '@/utils/objectToTableItems';
|
2023-10-24 17:21:39 +00:00
|
|
|
|
|
|
|
describe('objectArray.ts', () => {
|
|
|
|
it('converts object array', () => {
|
|
|
|
const originalObj = {
|
|
|
|
XXX1: [{ Profit: 20 }, { Loss: 50 }],
|
|
|
|
XXX2: [{ Profit: 50 }, { Loss: 21 }],
|
|
|
|
};
|
|
|
|
const expected = [
|
|
|
|
{ metric: 'Profit', XXX1: 20, XXX2: 50 },
|
|
|
|
{ metric: 'Loss', XXX1: 50, XXX2: 21 },
|
|
|
|
];
|
|
|
|
const expected2 = [
|
|
|
|
{ settings: 'Profit', XXX1: 20, XXX2: 50 },
|
|
|
|
{ settings: 'Loss', XXX1: 50, XXX2: 21 },
|
|
|
|
];
|
|
|
|
expect(formatObjectForTable(originalObj, 'metric')).toEqual(expected);
|
|
|
|
expect(formatObjectForTable(originalObj, 'settings')).toEqual(expected2);
|
|
|
|
});
|
|
|
|
});
|