|
|
@ -16,9 +16,8 @@ function getDisplayProcessorFromConfig(config: FieldConfig) { |
|
|
|
function assertSame(input: any, processors: DisplayProcessor[], match: DisplayValue) { |
|
|
|
function assertSame(input: any, processors: DisplayProcessor[], match: DisplayValue) { |
|
|
|
processors.forEach(processor => { |
|
|
|
processors.forEach(processor => { |
|
|
|
const value = processor(input); |
|
|
|
const value = processor(input); |
|
|
|
expect(value.text).toEqual(match.text); |
|
|
|
for (const key of Object.keys(match)) { |
|
|
|
if (match.hasOwnProperty('numeric')) { |
|
|
|
expect((value as any)[key]).toEqual((match as any)[key]); |
|
|
|
expect(value.numeric).toEqual(match.numeric); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@ -89,6 +88,27 @@ describe('Process simple display values', () => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe('Process null values', () => { |
|
|
|
|
|
|
|
const processors = [ |
|
|
|
|
|
|
|
getDisplayProcessorFromConfig({ |
|
|
|
|
|
|
|
min: 0, |
|
|
|
|
|
|
|
max: 100, |
|
|
|
|
|
|
|
thresholds: { |
|
|
|
|
|
|
|
mode: ThresholdsMode.Absolute, |
|
|
|
|
|
|
|
steps: [ |
|
|
|
|
|
|
|
{ value: -Infinity, color: '#000' }, |
|
|
|
|
|
|
|
{ value: 0, color: '#100' }, |
|
|
|
|
|
|
|
{ value: 100, color: '#200' }, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('Null should get -Infinity (base) color', () => { |
|
|
|
|
|
|
|
assertSame(null, processors, { text: '', numeric: NaN, color: '#000' }); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('Format value', () => { |
|
|
|
describe('Format value', () => { |
|
|
|
it('should return if value isNaN', () => { |
|
|
|
it('should return if value isNaN', () => { |
|
|
|
const valueMappings: ValueMapping[] = []; |
|
|
|
const valueMappings: ValueMapping[] = []; |
|
|
|