frequi_origin/tests/unit/objectArray.spec.ts
2024-07-05 14:34:17 +02:00

22 lines
725 B
TypeScript

import { describe, it, expect } from 'vitest';
import { formatObjectForTable } from '@/utils/objectToTableItems';
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);
});
});