From 77347a37b1741a592c46cf5ff7cd5f8d812795b3 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Mon, 10 Jan 2022 14:16:07 +0000 Subject: [PATCH] Add tests to ensure infinite value mappings work (#43858) --- .../src/utils/valueMappings.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/grafana-data/src/utils/valueMappings.test.ts b/packages/grafana-data/src/utils/valueMappings.test.ts index 4a2dcd63299..11e76aefc94 100644 --- a/packages/grafana-data/src/utils/valueMappings.test.ts +++ b/packages/grafana-data/src/utils/valueMappings.test.ts @@ -6,6 +6,14 @@ const testSet1: ValueMapping[] = [ type: MappingType.ValueToText, options: { '11': { text: 'elva' } }, }, + { + type: MappingType.ValueToText, + options: { Infinity: { text: 'wow infinity!' } }, + }, + { + type: MappingType.ValueToText, + options: { '-Infinity': { text: 'wow negative infinity!' } }, + }, { type: MappingType.RangeToText, options: { @@ -94,6 +102,16 @@ describe('Format value with value mappings', () => { expect(getValueMappingResult(testSet1, value)).toEqual({ text: 'elva' }); }); + it('should return match result for Infinity', () => { + const value = Infinity; + expect(getValueMappingResult(testSet1, value)).toEqual({ text: 'wow infinity!' }); + }); + + it('should return match result for -Infinity', () => { + const value = -Infinity; + expect(getValueMappingResult(testSet1, value)).toEqual({ text: 'wow negative infinity!' }); + }); + it('should return match result with number value', () => { const value = 11; expect(getValueMappingResult(testSet1, value)).toEqual({ text: 'elva' });