From 413aba109dff783c8413e453c97f049b3ce088fb Mon Sep 17 00:00:00 2001 From: Jordan Arldt Date: Thu, 15 Jun 2023 09:49:10 -0500 Subject: [PATCH] fix: STRF-10878 Fix money symbol position when setting is capitalized (#271) --- helpers/money.js | 2 +- spec/helpers/money.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/helpers/money.js b/helpers/money.js index 8911f72..351bea9 100644 --- a/helpers/money.js +++ b/helpers/money.js @@ -44,7 +44,7 @@ const factory = globals => { decimalToken ); - return money.currency_location === 'left' + return money.currency_location.toLowerCase() === 'left' ? money.currency_token + ' ' + value : value + ' ' + money.currency_token; }; diff --git a/spec/helpers/money.js b/spec/helpers/money.js index 43cae36..f121556 100644 --- a/spec/helpers/money.js +++ b/spec/helpers/money.js @@ -56,6 +56,26 @@ describe('money helper', function() { ], done); }); + it('should correctly set currency position regardless of location capitalization - [STRF-10878]', function(done) { + const settingsWithCapitalizedLocation = { + money: { + currency_location: "Left", + currency_token: "$", + decimal_places: 2, + thousands_token: ',', + decimal_token: '.', + } + }; + + const runTestCases = testRunner({ context, siteSettings: settingsWithCapitalizedLocation }); + runTestCases([ + { + input: '{{money price}}', + output: '$ 1,234.56', + }, + ], done); + }); + it('should throw an exception if the price value parameter has an invalid type', function(done) { renderString('{{money "hello"}}').catch(err => { expect(err.message).to.equal("money helper accepts only Number's as first parameter");