From d2e46b198efa0910943c6144f232230c6a1a72ce Mon Sep 17 00:00:00 2001 From: MGJamJam Date: Wed, 10 Jul 2024 11:48:55 -0300 Subject: [PATCH] add unit tests for getSmallerInterval --- src/utils/intervalUtils.test.ts | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/utils/intervalUtils.test.ts b/src/utils/intervalUtils.test.ts index 4c9ed9f..889e997 100644 --- a/src/utils/intervalUtils.test.ts +++ b/src/utils/intervalUtils.test.ts @@ -1,4 +1,30 @@ -import { calculateQueryInterval } from './intervalUtils'; +import { calculateQueryInterval, getSmallerInterval } from './intervalUtils'; + +describe('getSmallerInterval', () => { + it('should return smaller interval for MINUTE and HOUR interval', () => { + //arrange && act + const result = getSmallerInterval('HOUR', 'MINUTE'); + + //assert + expect(result).toEqual('MINUTE'); + }); + + it('should return smaller interval for HOUR and DAY interval', () => { + //arrange && act + const result = getSmallerInterval('DAY', 'HOUR'); + + //assert + expect(result).toEqual('HOUR'); + }); + + it('should return smaller interval for DAY and MONTH interval', () => { + //arrange && act + const result = getSmallerInterval('DAY', 'MONTH'); + + //assert + expect(result).toEqual('DAY'); + }); +}); describe('calculateQueryInterval', () => { it('should return correct given interval if interval is not AUTO', () => {