From c782d82ae39e0cd33f18a971948b6be341e938ca Mon Sep 17 00:00:00 2001 From: Chirag Madlani Date: Thu, 7 Jul 2022 18:19:46 +0530 Subject: [PATCH] test(ui): unit tests added for profilerUtils (#5922) --- .../ui/src/utils/ProfilerUtils.test.ts | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 openmetadata-ui/src/main/resources/ui/src/utils/ProfilerUtils.test.ts diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/ProfilerUtils.test.ts b/openmetadata-ui/src/main/resources/ui/src/utils/ProfilerUtils.test.ts new file mode 100644 index 00000000000..57c533d9714 --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/utils/ProfilerUtils.test.ts @@ -0,0 +1,50 @@ +import { + getImageWithResolutionAndFallback, + getRoundedValue, + ImageQuality, +} from './ProfilerUtils'; + +const mockImageList = { + image: 'image', + image192: 'image192', + image24: 'image24', + image32: 'image32', + image48: 'image48', + image512: 'image512', + image72: 'image72', +}; + +const mockImageListWithLowQuality = { + image: 'image', +}; + +describe('Test ProfilerUtils', () => { + it('getImageWithResolutionAndFallback should return Image with specified quality if present', () => { + expect( + getImageWithResolutionAndFallback(ImageQuality['6x'], mockImageList) + ).toEqual(mockImageList.image512); + }); + + it('getImageWithResolutionAndFallback should return lower quality if asked quality is not present', () => { + expect( + getImageWithResolutionAndFallback( + ImageQuality['5x'], + mockImageListWithLowQuality + ) + ).toEqual(mockImageList.image); + expect( + getImageWithResolutionAndFallback( + ImageQuality['5x'], + mockImageListWithLowQuality + ) + ).not.toEqual(mockImageList.image512); + }); + + it('getRoundedValue should return integer value as it is', () => { + expect(getRoundedValue(12)).toEqual(12); + }); + + it('getRoundedValue should other values as it is', () => { + expect(getRoundedValue(false)).toEqual(false); + }); +});