fixing / adding tests

This commit is contained in:
ppisljar 2016-12-07 22:52:52 +01:00
parent 44fe11a218
commit 91d921d3d8
7 changed files with 41 additions and 20 deletions

View file

@ -108,9 +108,8 @@ describe('Vislib AxisTitle Class Test Suite', function () {
dataObj = new Data(data, new PersistedState());
const visConfig = new VisConfig({
type: 'histogram',
el: el.node()
}, data, new PersistedState());
type: 'histogram'
}, data, new PersistedState(), el.node());
const xAxisConfig = new AxisConfig(visConfig, {
position: 'bottom',
title: {

View file

@ -96,9 +96,8 @@ describe('Vislib ChartTitle Class Test Suite', function () {
type: 'histogram',
title: {
'text': 'rows'
},
el: el.node()
}, data, persistedState);
}
}, data, persistedState, el.node());
chartTitle = new ChartTitle(visConfig);
}));

View file

@ -72,9 +72,8 @@ dateHistogramArray.forEach(function (data, i) {
describe('layout Method', function () {
beforeEach(function () {
const visConfig = new VisConfig({
el: vis.el,
type: 'histogram'
}, data, persistedState);
}, data, persistedState, vis.el);
testLayout = new Layout(visConfig);
});

View file

@ -76,9 +76,8 @@ describe('Vislib VisConfig Class Test Suite', function () {
.node();
visConfig = new VisConfig({
type: 'point_series',
el: el
}, data, new PersistedState());
type: 'point_series'
}, data, new PersistedState(), el);
}));
describe('get Method', function () {

View file

@ -95,9 +95,8 @@ describe('Vislib xAxis Class Test Suite', function () {
.attr('class', 'x-axis-div');
const visConfig = new VisConfig({
el: $('.x-axis-div')[0],
type: 'histogram'
}, data, persistedState);
}, data, persistedState, $('.x-axis-div')[0]);
xAxis = new Axis(visConfig, {
type: 'category',
id: 'CategoryAxis-1'

View file

@ -76,9 +76,8 @@ function createData(seriesData) {
buildYAxis = function (params) {
const visConfig = new VisConfig({
el: node,
type: 'histogram'
}, data, persistedState);
}, data, persistedState, node);
return new YAxis(visConfig, _.merge({}, {
id: 'ValueAxis-1',
type: 'value',

View file

@ -22,12 +22,14 @@ const dataTypesArray = [
['stackedSeries', stackedSeries],
];
describe('Vislib Heatmap Cyart Test Suite', function () {
describe('Vislib Heatmap Chart Test Suite', function () {
dataTypesArray.forEach(function (dataType, i) {
const name = dataType[0];
const data = dataType[1];
describe('for ' + name + ' Data', function () {
let PersistedState;
let vislibVis;
let vis;
let persistedState;
const visLibParams = {
@ -36,14 +38,23 @@ describe('Vislib Heatmap Cyart Test Suite', function () {
addTooltip: true,
colorsNumber: 4,
colorSchema: 'yellow to red',
setColorRange: false,
colorsRange: []
};
function generateVis(opts = {}) {
const config = _.defaultsDeep({}, opts, visLibParams);
vis = vislibVis(config);
persistedState = new PersistedState();
vis.on('brush', _.noop);
vis.render(data, persistedState);
}
beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
vis = Private(FixturesVislibVisFixtureProvider)(visLibParams);
persistedState = new (Private(PersistedStatePersistedStateProvider))();
vis.on('brush', _.noop);
vis.render(data, persistedState);
vislibVis = Private(FixturesVislibVisFixtureProvider);
PersistedState = Private(PersistedStatePersistedStateProvider);
generateVis();
}));
afterEach(function () {
@ -122,6 +133,22 @@ describe('Vislib Heatmap Cyart Test Suite', function () {
});
});
});
it('should define default colors', function () {
expect(persistedState.get('vis.defaultColors')).to.not.be(undefined);
});
it('should set custom range', function () {
generateVis({
setColorRange: true,
colorsRange: [{ value: 0}, { value: 200 }, { value: 400 }, { value: 500 }]
});
const labels = vis.getLegendLabels();
expect(labels[0]).to.be('> 0');
expect(labels[1]).to.be('> 200');
expect(labels[2]).to.be('> 400');
expect(labels[3]).to.be('> 500');
});
});
});
});