From 8628c30a2ced1ae2c7296fa3cc71a3eb6fdeb66e Mon Sep 17 00:00:00 2001 From: Vadzim Tsupryk Date: Tue, 16 Feb 2021 22:31:28 +0300 Subject: [PATCH] Add amount_with_apostrophe_separator money format --- packages/theme-currency/currency.js | 3 +++ packages/theme-currency/currency.test.js | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/packages/theme-currency/currency.js b/packages/theme-currency/currency.js index 889b9b63..272b2d32 100644 --- a/packages/theme-currency/currency.js +++ b/packages/theme-currency/currency.js @@ -60,6 +60,9 @@ export function formatMoney(cents, format) { case 'amount_no_decimals_with_comma_separator': value = formatWithDelimiters(cents, 0, '.', ','); break; + case 'amount_with_apostrophe_separator': + value = formatWithDelimiters(cents, 2, "'", '.'); + break; } return formatString.replace(placeholderRegex, value); diff --git a/packages/theme-currency/currency.test.js b/packages/theme-currency/currency.test.js index 16fdbb3a..adb3a4b4 100644 --- a/packages/theme-currency/currency.test.js +++ b/packages/theme-currency/currency.test.js @@ -33,4 +33,12 @@ describe("currency.formatMoney", () => { ); expect(value).toBe("$10.000"); }); + + test(`Formats a number 1000001 to a string of "$10'000.01"`, () => { + const value = formatMoney( + 1000001, + "${{amount_with_apostrophe_separator}}" + ); + expect(value).toBe("$10'000.01"); + }); });