From 261e5ebbd4ea63574a381ffefd6f7d14c4b77157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 19 Jun 2015 11:51:46 -0400 Subject: [PATCH] Fixed bug in singlestat panel and null value handling, #2189 --- public/app/components/kbn.js | 1 + public/test/specs/kbn-format-specs.js | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/public/app/components/kbn.js b/public/app/components/kbn.js index c9d2900f53b..aa5146c1538 100644 --- a/public/app/components/kbn.js +++ b/public/app/components/kbn.js @@ -406,6 +406,7 @@ function($, _, moment) { kbn.valueFormats.velocityknot = function(value, decimals) { return kbn.toFixed(value, decimals) + ' kn'; }; kbn.roundValue = function (num, decimals) { + if (num === null) { return null; } var n = Math.pow(10, decimals); return Math.round((n * num).toFixed(decimals)) / n; }; diff --git a/public/test/specs/kbn-format-specs.js b/public/test/specs/kbn-format-specs.js index d8a11c5a43c..1a5f60975c0 100644 --- a/public/test/specs/kbn-format-specs.js +++ b/public/test/specs/kbn-format-specs.js @@ -51,7 +51,12 @@ define([ }); }); - + describe('kbn roundValue', function() { + it('should should handle null value', function() { + var str = kbn.roundValue(null, 2); + expect(str).to.be(null); + }); + }); describe('calculateInterval', function() { it('1h 100 resultion', function() {