mirror of
https://github.com/apache/superset.git
synced 2026-04-17 23:25:05 +00:00
feat: Dynamic currency (#36416)
This commit is contained in:
committed by
GitHub
parent
896947c787
commit
f4474b2e3e
@@ -492,3 +492,59 @@ describe('BigNumberWithTrendline - Aggregation Tests', () => {
|
||||
expect(transformed.bigNumber).toStrictEqual(10);
|
||||
});
|
||||
});
|
||||
|
||||
test('BigNumberWithTrendline AUTO mode should detect single currency', () => {
|
||||
const props = generateProps(
|
||||
[
|
||||
{ __timestamp: 1607558400000, value: 1000, currency_code: 'USD' },
|
||||
{ __timestamp: 1607558500000, value: 2000, currency_code: 'USD' },
|
||||
],
|
||||
{
|
||||
yAxisFormat: ',.2f',
|
||||
currencyFormat: { symbol: 'AUTO', symbolPosition: 'prefix' },
|
||||
},
|
||||
);
|
||||
props.datasource.currencyCodeColumn = 'currency_code';
|
||||
|
||||
const transformed = transformProps(props);
|
||||
// The headerFormatter should include $ for USD
|
||||
expect(transformed.headerFormatter(1000)).toContain('$');
|
||||
});
|
||||
|
||||
test('BigNumberWithTrendline AUTO mode should use neutral formatting for mixed currencies', () => {
|
||||
const props = generateProps(
|
||||
[
|
||||
{ __timestamp: 1607558400000, value: 1000, currency_code: 'USD' },
|
||||
{ __timestamp: 1607558500000, value: 2000, currency_code: 'EUR' },
|
||||
],
|
||||
{
|
||||
yAxisFormat: ',.2f',
|
||||
currencyFormat: { symbol: 'AUTO', symbolPosition: 'prefix' },
|
||||
},
|
||||
);
|
||||
props.datasource.currencyCodeColumn = 'currency_code';
|
||||
|
||||
const transformed = transformProps(props);
|
||||
// With mixed currencies, should not show currency symbol
|
||||
const formatted = transformed.headerFormatter(1000);
|
||||
expect(formatted).not.toContain('$');
|
||||
expect(formatted).not.toContain('€');
|
||||
});
|
||||
|
||||
test('BigNumberWithTrendline should preserve static currency format', () => {
|
||||
const props = generateProps(
|
||||
[
|
||||
{ __timestamp: 1607558400000, value: 1000, currency_code: 'USD' },
|
||||
{ __timestamp: 1607558500000, value: 2000, currency_code: 'EUR' },
|
||||
],
|
||||
{
|
||||
yAxisFormat: ',.2f',
|
||||
currencyFormat: { symbol: 'GBP', symbolPosition: 'prefix' },
|
||||
},
|
||||
);
|
||||
props.datasource.currencyCodeColumn = 'currency_code';
|
||||
|
||||
const transformed = transformProps(props);
|
||||
// Static mode should always show £
|
||||
expect(transformed.headerFormatter(1000)).toContain('£');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user