[Lens] Fix suffix field format leaks to index pattern management (#107139)

This commit is contained in:
Anton Dosov 2021-08-02 12:59:56 +02:00 committed by GitHub
parent c048f71626
commit 1b315bb01d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View file

@ -31,6 +31,7 @@ export const unitSuffixesLong: Record<TimeScaleUnit, string> = {
export function getSuffixFormatter(formatFactory: FormatFactory): FieldFormatInstanceType {
return class SuffixFormatter extends FieldFormat {
static id = 'suffix';
static hidden = true; // Don't want this format to appear in index pattern editor
static title = i18n.translate('xpack.lens.fieldFormats.suffix.title', {
defaultMessage: 'Suffix',
});

View file

@ -42,4 +42,11 @@ describe('suffix formatter', () => {
expect(result).toEqual('');
});
it('should be a hidden formatter', () => {
const convertMock = jest.fn((x) => '');
const formatFactory = jest.fn(() => ({ convert: convertMock }));
const SuffixFormatter = getSuffixFormatter((formatFactory as unknown) as FormatFactory);
expect(SuffixFormatter.hidden).toBe(true);
});
});