@lightdash/common 0.1459.2 → 0.1460.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "Format": {
34
34
  "type": "string",
35
- "enum": ["km", "mi", "usd", "gbp", "eur", "id", "percent"]
35
+ "enum": ["km", "mi", "usd", "gbp", "eur", "jpy", "id", "percent"]
36
36
  },
37
37
  "Urls": {
38
38
  "type": "array",
@@ -221,6 +221,7 @@ export declare enum Format {
221
221
  USD = "usd",
222
222
  GBP = "gbp",
223
223
  EUR = "eur",
224
+ JPY = "jpy",
224
225
  ID = "id",
225
226
  PERCENT = "percent"
226
227
  }
@@ -169,6 +169,7 @@ var Format;
169
169
  Format["USD"] = "usd";
170
170
  Format["GBP"] = "gbp";
171
171
  Format["EUR"] = "eur";
172
+ Format["JPY"] = "jpy";
172
173
  Format["ID"] = "id";
173
174
  Format["PERCENT"] = "percent";
174
175
  })(Format = exports.Format || (exports.Format = {}));
@@ -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
  });
@@ -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 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/common",
3
- "version": "0.1459.2",
3
+ "version": "0.1460.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [