mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
fixing tabifyAggResponse (#61214)
This commit is contained in:
parent
fe2ae7ea0d
commit
cf5c8f60bb
2 changed files with 21 additions and 7 deletions
|
@ -106,13 +106,13 @@ describe('TabbedAggResponseWriter class', () => {
|
|||
});
|
||||
|
||||
test('adds the row to the array', () => {
|
||||
responseWriter.bucketBuffer = [{ id: 'col-0', value: 'US' }];
|
||||
responseWriter.metricBuffer = [{ id: 'col-1', value: 5 }];
|
||||
responseWriter.bucketBuffer = [{ id: 'col-0-1', value: 'US' }];
|
||||
responseWriter.metricBuffer = [{ id: 'col-1-2', value: 5 }];
|
||||
|
||||
responseWriter.row();
|
||||
|
||||
expect(responseWriter.rows.length).toEqual(1);
|
||||
expect(responseWriter.rows[0]).toEqual({ 'col-0': 'US', 'col-1': 5 });
|
||||
expect(responseWriter.rows[0]).toEqual({ 'col-0-1': 'US', 'col-1-2': 5 });
|
||||
});
|
||||
|
||||
test("doesn't add an empty row", () => {
|
||||
|
@ -120,6 +120,21 @@ describe('TabbedAggResponseWriter class', () => {
|
|||
|
||||
expect(responseWriter.rows.length).toEqual(0);
|
||||
});
|
||||
|
||||
test('doesnt add a partial row', () => {
|
||||
responseWriter.bucketBuffer = [{ id: 'col-0-1', value: 'US' }];
|
||||
responseWriter.row();
|
||||
|
||||
expect(responseWriter.rows.length).toEqual(0);
|
||||
});
|
||||
|
||||
test('adds partial row if partialRows is set to true', () => {
|
||||
responseWriter = createResponseWritter(splitAggConfig, { partialRows: true });
|
||||
responseWriter.bucketBuffer = [{ id: 'col-0-1', value: 'US' }];
|
||||
responseWriter.row();
|
||||
|
||||
expect(responseWriter.rows.length).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('response()', () => {
|
||||
|
|
|
@ -69,10 +69,9 @@ export class TabbedAggResponseWriter {
|
|||
rowBuffer[metric.id] = metric.value;
|
||||
});
|
||||
|
||||
const isPartialRow =
|
||||
this.partialRows && !this.columns.every(column => rowBuffer.hasOwnProperty(column.id));
|
||||
|
||||
if (!isEmpty(rowBuffer) && !isPartialRow) {
|
||||
const isPartialRow = !this.columns.every(column => rowBuffer.hasOwnProperty(column.id));
|
||||
const removePartial = isPartialRow && !this.partialRows;
|
||||
if (!isEmpty(rowBuffer) && !removePartial) {
|
||||
this.rows.push(rowBuffer);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue