diff --git a/src/ui/public/vis/__tests__/response_handlers/basic.js b/src/ui/public/vis/__tests__/response_handlers/basic.js index 48fe772941613c4..a8281b95742b6df 100644 --- a/src/ui/public/vis/__tests__/response_handlers/basic.js +++ b/src/ui/public/vis/__tests__/response_handlers/basic.js @@ -20,58 +20,26 @@ import ngMock from 'ng_mock'; import expect from 'expect.js'; import { VislibSeriesResponseHandlerProvider } from '../../response_handlers/vislib'; -import { VisProvider } from '../..'; -import fixtures from 'fixtures/fake_hierarchical_data'; -import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; - -const rowAgg = [ - { id: 'agg_1', type: 'avg', schema: 'metric', params: { field: 'bytes' } }, - { id: 'agg_2', type: 'terms', schema: 'split', params: { field: 'extension', rows: true } }, - { id: 'agg_3', type: 'terms', schema: 'segment', params: { field: 'machine.os' } }, - { id: 'agg_4', type: 'terms', schema: 'segment', params: { field: 'geo.src' } } -]; - describe('Basic Response Handler', function () { let basicResponseHandler; - let indexPattern; - let Vis; beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { basicResponseHandler = Private(VislibSeriesResponseHandlerProvider).handler; - Vis = Private(VisProvider); - indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); })); - it('calls hierarchical converter if isHierarchical is set to true', () => { - const vis = new Vis(indexPattern, { - type: 'pie', - aggs: rowAgg - }); - basicResponseHandler(vis, fixtures.threeTermBuckets).then(data => { - expect(data).to.not.be.an('undefined'); - expect(data.rows[0].slices).to.not.be.an('undefined'); - expect(data.rows[0].series).to.be.an('undefined'); - }); - }); - it('returns empty object if conversion failed', () => { - basicResponseHandler({}, {}).then(data => { + basicResponseHandler({}).then(data => { expect(data).to.not.be.an('undefined'); expect(data.rows).to.equal([]); }); }); - it('returns converted data', () => { - const vis = new Vis(indexPattern, { - type: 'histogram', - aggs: rowAgg.slice(0, 3) - }); - basicResponseHandler(vis, fixtures.threeTermBuckets).then(data => { + it('returns empty object if no data was found', () => { + basicResponseHandler({ columns: [{ id: '1', title: '1', aggConfig: {} }], rows: [] }).then(data => { expect(data).to.not.be.an('undefined'); - expect(data.rows[0].slices).to.be.an('undefined'); - expect(data.rows[0].series).to.not.be.an('undefined'); + expect(data.rows).to.equal([]); }); }); diff --git a/src/ui/public/vis/response_handlers/vislib.js b/src/ui/public/vis/response_handlers/vislib.js index 820bb787453be6a..8af6d87550238b9 100644 --- a/src/ui/public/vis/response_handlers/vislib.js +++ b/src/ui/public/vis/response_handlers/vislib.js @@ -26,8 +26,9 @@ function convertTableGroup(tableGroup, convertTable) { const tables = tableGroup.tables; const firstChild = tables[0]; - if (firstChild.columns) { + if (!tables.length) return; + if (firstChild.columns) { const chart = convertTable(firstChild); // if chart is within a split, assign group title to its label if (tableGroup.$parent) { @@ -36,8 +37,6 @@ function convertTableGroup(tableGroup, convertTable) { return chart; } - if (!tables.length) return; - const out = {}; let outList;