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

Commit

Permalink
Add amount_with_apostrophe_separator money format
Browse files Browse the repository at this point in the history
  • Loading branch information
meecrobe committed Feb 16, 2021
1 parent a903aad commit 8628c30
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/theme-currency/currency.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions packages/theme-currency/currency.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});

0 comments on commit 8628c30

Please sign in to comment.