PanelInspector: Adds a Raw display mode but defaults to Formatted display mode (#27306)

* PanelInspector: Fields with overrides are formatted correct in CSV

* Refactor: adds raw format

* Refactor: changes switch to Formatted values

* Tests: adds tests for applyRawFieldOverrides and getRawDisplayProcessor

* Test: change to utc timeZone

* Refactor: changes after PR comments
This commit is contained in:
Hugo Häggmark
2020-09-04 11:21:24 +02:00
committed by GitHub
parent ae385983f4
commit bba4770509
10 changed files with 356 additions and 112 deletions
@@ -1,4 +1,4 @@
import { getDisplayProcessor } from './displayProcessor';
import { getDisplayProcessor, getRawDisplayProcessor } from './displayProcessor';
import { DisplayProcessor, DisplayValue } from '../types/displayValue';
import { MappingType, ValueMapping } from '../types/valueMapping';
import { Field, FieldConfig, FieldType, GrafanaTheme, Threshold, ThresholdsMode } from '../types';
@@ -326,3 +326,27 @@ describe('Date display options', () => {
});
});
});
describe('getRawDisplayProcessor', () => {
const processor = getRawDisplayProcessor();
const date = new Date('2020-01-01T00:00:00.000Z');
const timestamp = date.valueOf();
it.each`
value | expected
${0} | ${'0'}
${13.37} | ${'13.37'}
${true} | ${'true'}
${false} | ${'false'}
${date} | ${`${date}`}
${timestamp} | ${'1577836800000'}
${'a string'} | ${'a string'}
${null} | ${'null'}
${undefined} | ${'undefined'}
${{ value: 0, label: 'a label' }} | ${'[object Object]'}
`('when called with value:{$value}', ({ value, expected }) => {
const result = processor(value);
expect(result).toEqual({ text: expected, numeric: null });
});
});