Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.11] fix time scaling bugs (#86444) #86644

Merged
merged 1 commit into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,9 @@ describe('IndexPattern Data Source', () => {
"outputColumnId": Array [
"col1",
],
"outputColumnName": Array [
"Count of records",
],
"targetUnit": Array [
"h",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,20 @@ describe('suffix formatter', () => {
expect(convertMock).toHaveBeenCalledWith(12345);
expect(formatFactory).toHaveBeenCalledWith({ id: 'nestedFormatter', params: nestedParams });
});

it('should not add suffix to empty strings', () => {
const convertMock = jest.fn((x) => '');
const formatFactory = jest.fn(() => ({ convert: convertMock }));
const SuffixFormatter = getSuffixFormatter((formatFactory as unknown) as FormatFactory);
const nestedParams = { abc: 123 };
const formatterInstance = new SuffixFormatter({
unit: 'h',
id: 'nestedFormatter',
params: nestedParams,
});

const result = formatterInstance.convert(12345);

expect(result).toEqual('');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ export function getSuffixFormatter(formatFactory: FormatFactory) {
val
);

// do not add suffixes to empty strings
if (formattedValue === '') {
return '';
}

if (suffix) {
return `${formattedValue}${suffix}`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ function getExpressionForLayer(
dateColumnId: [firstDateHistogramColumn![0]],
inputColumnId: [id],
outputColumnId: [id],
outputColumnName: [col.label],
targetUnit: [col.timeScale!],
},
};
Expand Down