Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('point series editor', function () {
});

it('should update series when new agg is added', function () {
const aggConfig = new AggConfig($parentScope.vis, { type: 'avg', schema: 'metric', params: { field: 'bytes' } });
const aggConfig = new AggConfig($parentScope.vis.aggs, { type: 'avg', schema: 'metric', params: { field: 'bytes' } });
$parentScope.vis.aggs.push(aggConfig);
$parentScope.$digest();
expect($parentScope.editorState.params.seriesParams.length).to.be(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,8 @@ function discoverController(
schema: 'segment',
params: {
field: $scope.opts.timefield,
interval: $state.interval
interval: $state.interval,
timeRange: timefilter.getTime(),
}
}
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export function CoordinateMapsVisualizationProvider(Notifier, Private) {
return;
}

const indexPatternName = agg._indexPattern.id;
const indexPatternName = agg.getIndexPattern().id;
const field = agg.fieldName();
const filter = { meta: { negate: false, index: indexPatternName } };
filter[filterName] = { ignore_unmapped: true };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function makeGeoJsonResponseHandler() {

//double conversion, first to table, then to geojson
//This is to future-proof this code for Canvas-refactoring
const tabifiedResponse = tabifyAggResponse(vis.getAggConfig(), esResponse);
const tabifiedResponse = tabifyAggResponse(vis.getAggConfig(), esResponse, { partialRows: true });
lastGeoJsonResponse = convertToGeoJson(tabifiedResponse);

return lastGeoJsonResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,9 @@
*/

import expect from 'expect.js';
import ngMock from 'ng_mock';
import { PointSeriesAddToSiriProvider } from '../_add_to_siri';
import { addToSiri } from '../_add_to_siri';

describe('addToSiri', function () {
let addToSiri;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
addToSiri = Private(PointSeriesAddToSiriProvider);
}));

it('creates a new series the first time it sees an id', function () {
const series = new Map();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,20 @@
*/

import expect from 'expect.js';
import ngMock from 'ng_mock';
import { VisProvider } from '../../../vis';
import { AggConfig } from '../../../vis/agg_config';
import { AggType } from '../../../agg_types/agg_type';
import { PointSeriesFakeXAxisProvider } from '../_fake_x_aspect';
import { makeFakeXAspect } from '../_fake_x_aspect';

describe('makeFakeXAspect', function () {

let makeFakeXAspect;
let Vis;
let indexPattern;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
Vis = Private(VisProvider);
indexPattern = Private(VisProvider);
makeFakeXAspect = Private(PointSeriesFakeXAxisProvider);
}));

it('creates an object that looks like an aspect', function () {
const vis = new Vis(indexPattern, { type: 'histogram' });
const aspect = makeFakeXAspect(vis);
const aspect = makeFakeXAspect();

expect(aspect)
.to.have.property('i', -1)
.and.have.property('aggConfig')
.and.have.property('title');
.and.have.property('aggConfig');

expect(aspect.aggConfig)
.to.be.an(AggConfig)
.to.have.property('fieldFormatter')
.and.to.have.property('type');

expect(aspect.aggConfig.type)
Expand Down
15 changes: 5 additions & 10 deletions src/ui/public/agg_response/point_series/__tests__/_get_aspects.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,16 @@ import moment from 'moment';
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { VisProvider } from '../../../vis';
import { AggConfig } from '../../../vis/agg_config';
import { PointSeriesGetAspectsProvider } from '../_get_aspects';
import { getAspects } from '../_get_aspects';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';

describe('getAspects', function () {
let Vis;
let indexPattern;
let getAspects;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
Vis = Private(VisProvider);
getAspects = Private(PointSeriesGetAspectsProvider);
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
}));

Expand Down Expand Up @@ -114,7 +111,7 @@ describe('getAspects', function () {
it('produces an aspect object for each of the aspect types found in the columns', function () {
init(1, 1, 1);

const aspects = getAspects(vis, table);
const aspects = getAspects(table);
validate(aspects.x, 0);
validate(aspects.series, 1);
validate(aspects.y, 2);
Expand All @@ -123,7 +120,7 @@ describe('getAspects', function () {
it('uses arrays only when there are more than one aspect of a specific type', function () {
init(0, 1, 2);

const aspects = getAspects(vis, table);
const aspects = getAspects(table);

validate(aspects.x, 0);
expect(aspects.series == null).to.be(true);
Expand All @@ -137,22 +134,20 @@ describe('getAspects', function () {
init(0, 2, 1);

expect(function () {
getAspects(vis, table);
getAspects(table);
}).to.throwError(TypeError);
});

it('creates a fake x aspect if the column does not exist', function () {
init(0, 0, 1);

const aspects = getAspects(vis, table);
const aspects = getAspects(table);

expect(aspects.x)
.to.be.an('object')
.and.have.property('i', -1)
.and.have.property('aggConfig')
.and.have.property('title');

expect(aspects.x.aggConfig).to.be.an(AggConfig);

});
});
10 changes: 1 addition & 9 deletions src/ui/public/agg_response/point_series/__tests__/_get_point.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,13 @@

import _ from 'lodash';
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { PointSeriesGetPointProvider } from '../_get_point';
import { getPoint } from '../_get_point';

describe('getPoint', function () {

let getPoint;

const truthFormatted = { fieldFormatter: _.constant(_.constant(true)) };
const identFormatted = { fieldFormatter: _.constant(_.identity) };

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
getPoint = Private(PointSeriesGetPointProvider);
}));

describe('Without series aspect', function () {
let seriesAspect;
let xAspect;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,11 @@

import _ from 'lodash';
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { PointSeriesGetSeriesProvider } from '../_get_series';
import { getSeries } from '../_get_series';

describe('getSeries', function () {
let getSeries;

const agg = { fieldFormatter: _.constant(_.identity) };

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
getSeries = Private(PointSeriesGetSeriesProvider);
}));

function wrapRows(row) {
return row.map(function (v) {
return { value: v };
Expand Down
25 changes: 9 additions & 16 deletions src/ui/public/agg_response/point_series/__tests__/_init_x_axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,29 @@

import _ from 'lodash';
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { PointSeriesInitXAxisProvider } from '../_init_x_axis';
import { initXAxis } from '../_init_x_axis';

describe('initXAxis', function () {

let initXAxis;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
initXAxis = Private(PointSeriesInitXAxisProvider);
}));
const field = {};
const indexPattern = {};

const baseChart = {
aspects: {
x: {
aggConfig: {
fieldFormatter: _.constant({}),
write: _.constant({ params: {} }),
aggConfigs: {},
getIndexPattern: () => {
return indexPattern;
},
type: {}
},
title: 'label'
}
}
};
const field = {};
const indexPattern = {};

it('sets the xAxisFormatter if the agg is not ordered', function () {
const chart = _.cloneDeep(baseChart);
Expand All @@ -60,9 +57,7 @@ describe('initXAxis', function () {
chart.aspects.x.aggConfig.params = {
field: field
};
chart.aspects.x.aggConfig.vis = {
indexPattern: indexPattern
};
chart.aspects.x.aggConfig.aggConfigs.indexPattern = indexPattern;

initXAxis(chart);
expect(chart)
Expand All @@ -84,9 +79,7 @@ describe('initXAxis', function () {
chart.aspects.x.aggConfig.params = {
field: field
};
chart.aspects.x.aggConfig.vis = {
indexPattern: indexPattern
};
chart.aspects.x.aggConfig.aggConfigs.indexPattern = indexPattern;

initXAxis(chart);
expect(chart)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,10 @@

import _ from 'lodash';
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { PointSeriesInitYAxisProvider } from '../_init_y_axis';
import { initYAxis } from '../_init_y_axis';

describe('initYAxis', function () {

let initYAxis;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
initYAxis = Private(PointSeriesInitYAxisProvider);
}));

function agg() {
return {
Expand Down
8 changes: 4 additions & 4 deletions src/ui/public/agg_response/point_series/__tests__/_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('pointSeriesChartDataFromTable', function () {
table.columns = [ { aggConfig: agg } ];
table.rows.push([ result ]);

const chartData = pointSeriesChartDataFromTable(vis, table);
const chartData = pointSeriesChartDataFromTable(table);

expect(chartData).to.be.an('object');
expect(chartData.series).to.be.an('array');
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('pointSeriesChartDataFromTable', function () {
table.rows.push([date, new AggConfigResult(y.agg, date, y.at(i))]);
});

const chartData = pointSeriesChartDataFromTable(vis, table);
const chartData = pointSeriesChartDataFromTable(table);

expect(chartData).to.be.an('object');
expect(chartData.series).to.be.an('array');
Expand Down Expand Up @@ -155,7 +155,7 @@ describe('pointSeriesChartDataFromTable', function () {
table.rows.push([dateResult, avgResult, maxResult]);
});

const chartData = pointSeriesChartDataFromTable(vis, table);
const chartData = pointSeriesChartDataFromTable(table);
expect(chartData).to.be.an('object');
expect(chartData.series).to.be.an('array');
expect(chartData.series).to.have.length(2);
Expand Down Expand Up @@ -235,7 +235,7 @@ describe('pointSeriesChartDataFromTable', function () {
table.rows.push([dateResult, termResult, avgResult, maxResult]);
});

const chartData = pointSeriesChartDataFromTable(vis, table);
const chartData = pointSeriesChartDataFromTable(table);
expect(chartData).to.be.an('object');
expect(chartData.series).to.be.an('array');
// one series for each extension, and then one for each metric inside
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import moment from 'moment';
import _ from 'lodash';
import sinon from 'sinon';
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { PointSeriesOrderedDateAxisProvider } from '../_ordered_date_axis';
import { orderedDateAxis } from '../_ordered_date_axis';

describe('orderedDateAxis', function () {

Expand All @@ -48,25 +47,18 @@ describe('orderedDateAxis', function () {
}
};

let orderedDateAxis;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
orderedDateAxis = Private(PointSeriesOrderedDateAxisProvider);
}));

describe('xAxisFormatter', function () {
it('sets the xAxisFormatter', function () {
const args = _.cloneDeep(baseArgs);
orderedDateAxis(args.vis, args.chart);
orderedDateAxis(args.chart);

expect(args.chart).to.have.property('xAxisFormatter');
expect(args.chart.xAxisFormatter).to.be.a('function');
});

it('formats values using moment, and returns strings', function () {
const args = _.cloneDeep(baseArgs);
orderedDateAxis(args.vis, args.chart);
orderedDateAxis(args.chart);

const val = '2014-08-06T12:34:01';
expect(args.chart.xAxisFormatter(val))
Expand All @@ -77,7 +69,7 @@ describe('orderedDateAxis', function () {
describe('ordered object', function () {
it('sets date: true', function () {
const args = _.cloneDeep(baseArgs);
orderedDateAxis(args.vis, args.chart);
orderedDateAxis(args.chart);

expect(args.chart)
.to.have.property('ordered');
Expand All @@ -89,21 +81,21 @@ describe('orderedDateAxis', function () {
it('relies on agg.buckets for the interval', function () {
const args = _.cloneDeep(baseArgs);
const spy = sinon.spy(args.chart.aspects.x.aggConfig.buckets, 'getInterval');
orderedDateAxis(args.vis, args.chart);
orderedDateAxis(args.chart);
expect(spy).to.have.property('callCount', 1);
});

it('sets the min/max when the buckets are bounded', function () {
const args = _.cloneDeep(baseArgs);
orderedDateAxis(args.vis, args.chart);
orderedDateAxis(args.chart);
expect(moment.isMoment(args.chart.ordered.min)).to.be(true);
expect(moment.isMoment(args.chart.ordered.max)).to.be(true);
});

it('does not set the min/max when the buckets are unbounded', function () {
const args = _.cloneDeep(baseArgs);
args.chart.aspects.x.aggConfig.buckets.getBounds = _.constant();
orderedDateAxis(args.vis, args.chart);
orderedDateAxis(args.chart);
expect(args.chart.ordered).to.not.have.property('min');
expect(args.chart.ordered).to.not.have.property('max');
});
Expand Down
Loading