|
| 1 | +import { UsageValues } from 'types'; |
| 2 | + |
| 3 | +import { calculateMultiHTTPUsage, calculateUsage, getTotalChecksPerMonth } from './checkUsageCalc'; |
| 4 | + |
| 5 | +describe('checkUsageCalc', () => { |
| 6 | + describe('getTotalChecksPerMonth', () => { |
| 7 | + it('should calculate total checks per month correctly when probeCount is 1', () => { |
| 8 | + const probeCount = 1; |
| 9 | + const frequencySeconds = 300; |
| 10 | + const result = getTotalChecksPerMonth(probeCount, frequencySeconds); |
| 11 | + expect(result).toBe(8928); |
| 12 | + }); |
| 13 | + |
| 14 | + it('should calculate total checks per month correctly when probeCount is bigger than 1', () => { |
| 15 | + const probeCount = 2; |
| 16 | + const frequencySeconds = 300; |
| 17 | + const result = getTotalChecksPerMonth(probeCount, frequencySeconds); |
| 18 | + expect(result).toBe(17856); |
| 19 | + }); |
| 20 | + |
| 21 | + it('should return 0 checks per month when probe count is 0', () => { |
| 22 | + const probeCount = 0; |
| 23 | + const frequencySeconds = 300; |
| 24 | + const result = getTotalChecksPerMonth(probeCount, frequencySeconds); |
| 25 | + expect(result).toBe(0); |
| 26 | + }); |
| 27 | + }); |
| 28 | + |
| 29 | + describe('calculateUsage', () => { |
| 30 | + it('should calculate usage correctly', () => { |
| 31 | + const params = { |
| 32 | + assertionCount: 1, |
| 33 | + probeCount: 1, |
| 34 | + frequencySeconds: 300, |
| 35 | + seriesPerProbe: 22, |
| 36 | + }; |
| 37 | + const expected: UsageValues = { |
| 38 | + checksPerMonth: 8928, |
| 39 | + activeSeries: 22, |
| 40 | + logsGbPerMonth: 0.01, |
| 41 | + dpm: 22, |
| 42 | + }; |
| 43 | + const result = calculateUsage(params); |
| 44 | + expect(result).toEqual(expected); |
| 45 | + }); |
| 46 | + |
| 47 | + it('should return 0 values when probe count is 0', () => { |
| 48 | + const params = { |
| 49 | + assertionCount: 1, |
| 50 | + probeCount: 0, |
| 51 | + frequencySeconds: 300, |
| 52 | + seriesPerProbe: 22, |
| 53 | + }; |
| 54 | + const expected: UsageValues = { |
| 55 | + checksPerMonth: 0, |
| 56 | + activeSeries: 0, |
| 57 | + logsGbPerMonth: 0, |
| 58 | + dpm: 0, |
| 59 | + }; |
| 60 | + const result = calculateUsage(params); |
| 61 | + expect(result).toEqual(expected); |
| 62 | + }); |
| 63 | + }); |
| 64 | + |
| 65 | + describe('calculateMultiHTTPUsage', () => { |
| 66 | + it('should calculate multi HTTP usage correctly', () => { |
| 67 | + const params = { |
| 68 | + assertionCount: 1, |
| 69 | + probeCount: 1, |
| 70 | + frequencySeconds: 300, |
| 71 | + seriesPerProbe: 33, |
| 72 | + }; |
| 73 | + const expected: UsageValues = { |
| 74 | + checksPerMonth: 8928, |
| 75 | + activeSeries: 33, |
| 76 | + logsGbPerMonth: 0.013847328, |
| 77 | + dpm: 33, |
| 78 | + }; |
| 79 | + const result = calculateMultiHTTPUsage(params); |
| 80 | + expect(result).toEqual(expected); |
| 81 | + }); |
| 82 | + |
| 83 | + it('should return 0 values when probe count is 0', () => { |
| 84 | + const params = { |
| 85 | + assertionCount: 1, |
| 86 | + probeCount: 0, |
| 87 | + frequencySeconds: 300, |
| 88 | + seriesPerProbe: 33, |
| 89 | + }; |
| 90 | + const expected: UsageValues = { |
| 91 | + checksPerMonth: 0, |
| 92 | + activeSeries: 0, |
| 93 | + logsGbPerMonth: 0, |
| 94 | + dpm: 0, |
| 95 | + }; |
| 96 | + const result = calculateMultiHTTPUsage(params); |
| 97 | + expect(result).toEqual(expected); |
| 98 | + }); |
| 99 | + }); |
| 100 | +}); |
0 commit comments