Skip to content
This repository was archived by the owner on Oct 20, 2023. It is now read-only.

Commit 7313c0c

Browse files
committed
Add amount_with_apostrophe_separator money format
1 parent a903aad commit 7313c0c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

packages/theme-currency/currency.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ export function formatMoney(cents, format) {
6060
case 'amount_no_decimals_with_comma_separator':
6161
value = formatWithDelimiters(cents, 0, '.', ',');
6262
break;
63+
case 'amount_with_apostrophe_separator':
64+
value = formatWithDelimiters(cents, 2, "'", '.');
65+
break;
6366
}
6467

6568
return formatString.replace(placeholderRegex, value);

packages/theme-currency/currency.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,12 @@ describe("currency.formatMoney", () => {
3333
);
3434
expect(value).toBe("$10.000");
3535
});
36+
37+
test(`Formats a number 1000001 to a string of "$10'000.01"`, () => {
38+
const value = formatMoney(
39+
1000001,
40+
"${{amount_with_apostrophe_separator}}"
41+
);
42+
expect(value).toBe("$10'000.01");
43+
});
3644
});

0 commit comments

Comments
 (0)