Add tests to ensure infinite value mappings work (#43858)

This commit is contained in:
Ashley Harrison 2022-01-10 14:16:07 +00:00 committed by GitHub
parent d350ed0f35
commit 77347a37b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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' });