From 740181c224d0444734beb151a142941c3d6e40e9 Mon Sep 17 00:00:00 2001 From: Jeremy Press Date: Fri, 27 Apr 2018 11:28:50 -0700 Subject: [PATCH] Chore: Round timer values to integers (#786) --- src/lib/Timer.js | 2 +- src/lib/__tests__/Timer-test.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/Timer.js b/src/lib/Timer.js index e15006752..6341a2995 100644 --- a/src/lib/Timer.js +++ b/src/lib/Timer.js @@ -45,7 +45,7 @@ class Timer { } time.end = global.performance.now(); - time.elapsed = time.end - time.start; + time.elapsed = Math.round(time.end - time.start); } /** diff --git a/src/lib/__tests__/Timer-test.js b/src/lib/__tests__/Timer-test.js index 929c97818..9c74f2edf 100644 --- a/src/lib/__tests__/Timer-test.js +++ b/src/lib/__tests__/Timer-test.js @@ -71,10 +71,10 @@ describe('lib/Timer', () => { it('should set the end prop, and calculate the elapsed time', () => { sandbox.stub(global.performance, 'now').returns(5); - Timer.times[tag] = { start: 3 }; + Timer.times[tag] = { start: 3.5 }; Timer.stop(tag); - expect(Timer.get(tag).elapsed).to.equal(2); // 5 - 3 = 2 + expect(Timer.get(tag).elapsed).to.equal(2); // 5 - 3.5 = 1.5, rounded = 2 }); });