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

Add amount_with_apostrophe_separator money format #150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
});
});