mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Changed null logic for range value mappings after PR comments
This commit is contained in:
parent
38ea11d110
commit
bbb7596113
@ -148,22 +148,9 @@ describe('Format value with value mappings', () => {
|
||||
expect(result.text).toEqual('<NULL>');
|
||||
});
|
||||
|
||||
it('should return if value is null and range to text mapping from is null', () => {
|
||||
it('should return if value is null and range to text mapping from and to is null', () => {
|
||||
const valueMappings: ValueMapping[] = [
|
||||
{ id: 0, operator: '', text: '<NULL>', type: MappingType.RangeToText, from: 'null', to: '10' },
|
||||
{ id: 1, operator: '', text: 'elva', type: MappingType.ValueToText, value: '11' },
|
||||
];
|
||||
const value = null;
|
||||
const { instance } = setup({ valueMappings });
|
||||
|
||||
const result = instance.getFirstFormattedValueMapping(valueMappings, value);
|
||||
|
||||
expect(result.text).toEqual('<NULL>');
|
||||
});
|
||||
|
||||
it('should return if value is null and range to text mapping to is null', () => {
|
||||
const valueMappings: ValueMapping[] = [
|
||||
{ id: 0, operator: '', text: '<NULL>', type: MappingType.RangeToText, from: '1', to: 'null' },
|
||||
{ id: 0, operator: '', text: '<NULL>', type: MappingType.RangeToText, from: 'null', to: 'null' },
|
||||
{ id: 1, operator: '', text: 'elva', type: MappingType.ValueToText, value: '11' },
|
||||
];
|
||||
const value = null;
|
||||
|
@ -91,7 +91,8 @@ export class Gauge extends PureComponent<Props> {
|
||||
value === null &&
|
||||
rangeToTextMapping.from &&
|
||||
rangeToTextMapping.to &&
|
||||
(rangeToTextMapping.from.toLowerCase() === 'null' || rangeToTextMapping.to.toLowerCase() === 'null')
|
||||
rangeToTextMapping.from.toLowerCase() === 'null' &&
|
||||
rangeToTextMapping.to.toLowerCase() === 'null'
|
||||
) {
|
||||
return allValueMappings.concat(rangeToTextMapping);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user