From 66746d7b53df74199a5c69090af882bcc39f43d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20Conradi=20=C3=98sthus?= Date: Wed, 16 Oct 2024 21:15:34 +0200 Subject: [PATCH] fix: failing test --- frontend/src/hooks/useTrafficData.test.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/src/hooks/useTrafficData.test.ts b/frontend/src/hooks/useTrafficData.test.ts index dfd0c8b7a5..c20a68bbc2 100644 --- a/frontend/src/hooks/useTrafficData.test.ts +++ b/frontend/src/hooks/useTrafficData.test.ts @@ -34,13 +34,27 @@ describe('traffic overage calculation', () => { expect(result).toBe(0); }); - it('should return 5 if overage this month is atleast 1 request above included', () => { + it('should return 0 if overage this month is atleast 1 request above included', () => { const dataUsage = 53_000_001; const includedTraffic = 53_000_000; const result = calculateOverageCost(dataUsage, includedTraffic); + expect(result).toBe(0); + }); + + it('should return 5 if overage this month is atleast 1M request above included', () => { + const dataUsage = 54_000_000; + const includedTraffic = 53_000_000; + const result = calculateOverageCost(dataUsage, includedTraffic); expect(result).toBe(5); }); + it('should return 10 if overage this month is > 2M request above included', () => { + const dataUsage = 55_100_000; + const includedTraffic = 53_000_000; + const result = calculateOverageCost(dataUsage, includedTraffic); + expect(result).toBe(10); + }); + it('doesnt estimate when having less than 5 days worth of data', () => { const now = new Date(); const period = toSelectablePeriod(now);