feat: Implement currencies formatter for saved metrics (#24517)

This commit is contained in:
Kamil Gabryjelski
2023-06-28 20:51:40 +02:00
committed by GitHub
parent e402c94a9f
commit 83ff4cd86a
61 changed files with 906 additions and 75 deletions

View File

@@ -158,5 +158,30 @@ describe('BigNumberWithTrendline', () => {
'1.23',
);
});
it('should format with datasource currency', () => {
const propsWithDatasource = {
...props,
datasource: {
...props.datasource,
currencyFormats: {
value: { symbol: 'USD', symbolPosition: 'prefix' },
},
metrics: [
{
label: 'value',
metric_name: 'value',
d3format: '.2f',
currency: `{symbol: 'USD', symbolPosition: 'prefix' }`,
},
],
},
};
const transformed = transformProps(propsWithDatasource);
// @ts-ignore
expect(transformed.headerFormatter(transformed.bigNumber)).toStrictEqual(
'$ 1.23',
);
});
});
});