diff --git a/client/core/src/filters/currency.js b/client/core/src/filters/currency.js index f96963882..d90fe963d 100644 --- a/client/core/src/filters/currency.js +++ b/client/core/src/filters/currency.js @@ -1,17 +1,17 @@ import ngModule from '../module'; /** - * Override angular currency formats a number adding symbol after value. + * Override angular currency formatting a number, adding symbol after value. * * @return {String} The formated number */ export default function currency() { return function(input, symbol, fractionSize) { - if (input === undefined || input === null || input === '') - return undefined; - if (typeof input == 'number' && fractionSize) + if (typeof input == 'number' && fractionSize) { input = input.toFixed(fractionSize); - return `${input} ${symbol}`; + return `${input} ${symbol}`; + } + return undefined; }; } ngModule.filter('currency', currency); diff --git a/client/core/src/filters/specs/currency.spec.js b/client/core/src/filters/specs/currency.spec.js new file mode 100644 index 000000000..38e4e19db --- /dev/null +++ b/client/core/src/filters/specs/currency.spec.js @@ -0,0 +1,27 @@ +fdescribe('Currency filter', () => { + let compile; + let $element; + + beforeEach(ngModule('client')); + + compile = html => { + inject(($compile, $rootScope) => { + $element = $compile(html)($rootScope); + $rootScope.$digest(); + }); + }; + + it('should return the value formatted with two decimals when the value is a number and you set it a 2 as param', () => { + let html = `