]> source.dussan.org Git - sonarqube.git/commitdiff
fix measure formatting when empty string is passed
authorStas Vilchik <vilchiks@gmail.com>
Thu, 19 Nov 2015 10:11:34 +0000 (11:11 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 19 Nov 2015 10:11:52 +0000 (11:11 +0100)
server/sonar-web/src/main/js/helpers/measures.js
server/sonar-web/tests/helpers/measures-test.js

index 23a27e9270e280bb22bf168d2ab32eeb8758a00b..dd8b4ea58547823beaaeddcc6c92a23618fe1362 100644 (file)
@@ -56,7 +56,7 @@ export function groupByDomain (metrics) {
  */
 
 function useFormatter (value, formatter) {
-  return value != null && formatter != null ?
+  return value != null && value !== '' && formatter != null ?
       formatter(value) : null;
 }
 
index e302e2db0ab28cd0a73b98cdf13048e7551cd2e9..503d6e3214a2998f23bd1c26838d435a96674b50 100644 (file)
@@ -146,6 +146,10 @@ describe('Measures', function () {
       expect(formatMeasure('random value', 'RANDOM_TYPE')).to.equal('random value');
     });
 
+    it('should return null if value is empty string', function () {
+      expect(formatMeasure('', 'PERCENT')).to.be.null;
+    });
+
     it('should not fail without parameters', function () {
       expect(formatMeasure()).to.be.null;
     });