Skip to content

Commit

Permalink
fix: STRF-10878 Fix money symbol position when setting is capitalized (
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanarldt authored Jun 15, 2023
1 parent 9955e92 commit 413aba1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion helpers/money.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
20 changes: 20 additions & 0 deletions spec/helpers/money.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 413aba1

Please sign in to comment.