From a527a88bdb189534791f5fa8fbdf410af81a8294 Mon Sep 17 00:00:00 2001 From: Stian Aune Date: Wed, 20 Nov 2019 19:58:43 +0100 Subject: [PATCH] Test diff bug fix. --- my-bois/src/helpers/diff.test.js | 48 ++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/my-bois/src/helpers/diff.test.js b/my-bois/src/helpers/diff.test.js index a929c28..a3b9a80 100644 --- a/my-bois/src/helpers/diff.test.js +++ b/my-bois/src/helpers/diff.test.js @@ -14,6 +14,18 @@ const programWithWarmup = { cooldownCpm: 20, }; +const programGis = { + id: "P016e68afbab3720762a67aa30c7fdb9f", + name: "Gisle 2", + cpm: 30, + warmupMin: 5, + warmupCpm: 20, + level: 18, + warmupLevel: 16, + cooldownLevel: 16, + cooldownCpm: 20 +}; + describe('diffString', () => { it("should show a plus before zero", () => { expect(diffString(0)).toBe("+0"); @@ -86,4 +98,40 @@ describe("calculateDiff", () => { expect(diff).toBe(0); }); + + it("should require 50 calories after 2.5 min of GIS", () => { + const diff = calculateDiff({ + program: programGis, + cooldownMin: -1, + minutes: 2, + seconds: 30, + calories: 53, + }); + + expect(diff).toBe(3); + }); + + it("should require 175 calories after 7.5 min of GIS", () => { + const diff = calculateDiff({ + program: programGis, + cooldownMin: -1, + minutes: 7, + seconds: 30, + calories: 175, + }); + + expect(diff).toBe(0); + }); + + it("should require 310 calories after 12.5 min of GIS", () => { + const diff = calculateDiff({ + program: programGis, + cooldownMin: 11, + minutes: 12, + seconds: 30, + calories: 311, + }); + + expect(diff).toBe(1); + }); });