From c816f9d8bb9efc1fc3dba9c86be53c942ecb8a93 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Fri, 4 Dec 2015 16:47:19 +0100 Subject: [PATCH] fix formatting of WORK_DUR measures --- server/sonar-web/src/main/js/helpers/measures.js | 4 ++-- server/sonar-web/tests/helpers/measures-test.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/sonar-web/src/main/js/helpers/measures.js b/server/sonar-web/src/main/js/helpers/measures.js index 639a7678266..81bf4454323 100644 --- a/server/sonar-web/src/main/js/helpers/measures.js +++ b/server/sonar-web/src/main/js/helpers/measures.js @@ -243,9 +243,9 @@ function durationFormatter (value) { var hoursInDay = window.SS.hoursInDay, isNegative = value < 0, absValue = Math.abs(value); - var days = Math.round(absValue / hoursInDay / 60); + var days = Math.floor(absValue / hoursInDay / 60); var remainingValue = absValue - days * hoursInDay * 60; - var hours = Math.round(remainingValue / 60); + var hours = Math.floor(remainingValue / 60); remainingValue -= hours * 60; return formatDuration(isNegative, days, hours, remainingValue); } diff --git a/server/sonar-web/tests/helpers/measures-test.js b/server/sonar-web/tests/helpers/measures-test.js index 503d6e3214a..cc8e7a4a25c 100644 --- a/server/sonar-web/tests/helpers/measures-test.js +++ b/server/sonar-web/tests/helpers/measures-test.js @@ -89,6 +89,7 @@ describe('Measures', function () { expect(formatMeasure(0, 'WORK_DUR')).to.equal('0'); expect(formatMeasure(5 * ONE_DAY, 'WORK_DUR')).to.equal('5d'); expect(formatMeasure(2 * ONE_HOUR, 'WORK_DUR')).to.equal('2h'); + expect(formatMeasure(40 * ONE_MINUTE, 'WORK_DUR')).to.equal('40min'); expect(formatMeasure(ONE_MINUTE, 'WORK_DUR')).to.equal('1min'); expect(formatMeasure(5 * ONE_DAY + 2 * ONE_HOUR, 'WORK_DUR')).to.equal('5d 2h'); expect(formatMeasure(2 * ONE_HOUR + ONE_MINUTE, 'WORK_DUR')).to.equal('2h 1min'); @@ -103,6 +104,7 @@ describe('Measures', function () { expect(formatMeasure(0, 'SHORT_WORK_DUR')).to.equal('0'); expect(formatMeasure(5 * ONE_DAY, 'SHORT_WORK_DUR')).to.equal('5d'); expect(formatMeasure(2 * ONE_HOUR, 'SHORT_WORK_DUR')).to.equal('2h'); + expect(formatMeasure(40 * ONE_MINUTE, 'SHORT_WORK_DUR')).to.equal('40min'); expect(formatMeasure(ONE_MINUTE, 'SHORT_WORK_DUR')).to.equal('1min'); expect(formatMeasure(5 * ONE_DAY + 2 * ONE_HOUR, 'SHORT_WORK_DUR')).to.equal('5d'); expect(formatMeasure(2 * ONE_HOUR + ONE_MINUTE, 'SHORT_WORK_DUR')).to.equal('2h'); -- 2.39.5