@lightdash/common 0.1459.2 → 0.1460.0
Sign up to get free protection for your applications and to get access to all the features.
package/dist/types/field.d.ts
CHANGED
package/dist/types/field.js
CHANGED
package/dist/types/field.test.js
CHANGED
@@ -70,4 +70,21 @@ describe('field util functions', () => {
|
|
70
70
|
expect((0, item_1.getItemId)(additionalMetric)).toEqual('table1_calc2');
|
71
71
|
});
|
72
72
|
});
|
73
|
+
describe('isFormat', () => {
|
74
|
+
it('should correctly identify valid formats', () => {
|
75
|
+
expect((0, field_1.isFormat)('km')).toBe(true);
|
76
|
+
expect((0, field_1.isFormat)('mi')).toBe(true);
|
77
|
+
expect((0, field_1.isFormat)('usd')).toBe(true);
|
78
|
+
expect((0, field_1.isFormat)('gbp')).toBe(true);
|
79
|
+
expect((0, field_1.isFormat)('eur')).toBe(true);
|
80
|
+
expect((0, field_1.isFormat)('jpy')).toBe(true);
|
81
|
+
expect((0, field_1.isFormat)('id')).toBe(true);
|
82
|
+
expect((0, field_1.isFormat)('percent')).toBe(true);
|
83
|
+
});
|
84
|
+
it('should return false for invalid formats', () => {
|
85
|
+
expect((0, field_1.isFormat)('invalid')).toBe(false);
|
86
|
+
expect((0, field_1.isFormat)(undefined)).toBe(false);
|
87
|
+
expect((0, field_1.isFormat)('')).toBe(false);
|
88
|
+
});
|
89
|
+
});
|
73
90
|
});
|
package/dist/utils/formatting.js
CHANGED
@@ -187,6 +187,7 @@ function getCustomFormatFromLegacy({ format, compact, round, }) {
|
|
187
187
|
case field_1.Format.EUR:
|
188
188
|
case field_1.Format.GBP:
|
189
189
|
case field_1.Format.USD:
|
190
|
+
case field_1.Format.JPY:
|
190
191
|
return {
|
191
192
|
type: field_1.CustomFormatType.CURRENCY,
|
192
193
|
currency: format.toUpperCase(),
|
@@ -63,6 +63,10 @@ describe('Formatting', () => {
|
|
63
63
|
type: field_1.CustomFormatType.CURRENCY,
|
64
64
|
currency: field_1.Format.EUR,
|
65
65
|
})).toEqual('€5.00');
|
66
|
+
expect((0, formatting_1.applyCustomFormat)(5, {
|
67
|
+
type: field_1.CustomFormatType.CURRENCY,
|
68
|
+
currency: field_1.Format.JPY,
|
69
|
+
})).toEqual('¥5');
|
66
70
|
});
|
67
71
|
test('if Format is percent it should return the right format', () => {
|
68
72
|
const percentFormat = {
|