Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1fd8f98
introducing AxisConfig class
ppisljar Sep 14, 2016
fe00e6f
adding ordered and values back to axis to make other parts of vislib …
ppisljar Sep 14, 2016
a2d8f51
fixing style of axis.js (indentation)
ppisljar Sep 14, 2016
5574d9e
fixing few mistakes ...
ppisljar Sep 14, 2016
c054582
fixing few mistakes ...
ppisljar Sep 14, 2016
978105a
fixing few mistakes ...
ppisljar Sep 14, 2016
7c8e149
renaming axis.scale to axis.axisScale
ppisljar Sep 14, 2016
8c82cac
removing comments
ppisljar Sep 14, 2016
f25401e
Merge branch 'vislib-axis-refactor' of github.com:elastic/kibana into…
Sep 14, 2016
5e36e09
fixing based on spalger comments
ppisljar Sep 15, 2016
79aeedd
removing extend ErrorHandler from Axis subclasses
ppisljar Sep 15, 2016
1015fbc
fixing indentation issue in dispatch.js
ppisljar Sep 15, 2016
d6937d3
forgot to remove super calls
ppisljar Sep 15, 2016
4257b75
fixing tests
ppisljar Sep 15, 2016
4f49b1f
adding scale type config
ppisljar Sep 15, 2016
942d6e9
fixing tests
ppisljar Sep 15, 2016
444ec0c
fixing tests
ppisljar Sep 15, 2016
a9d0a4b
fixing tests
ppisljar Sep 15, 2016
78f2566
fixing axisTitle tests
ppisljar Sep 15, 2016
65a616d
fixing layout tests
ppisljar Sep 15, 2016
2131a69
fixing layout tests
ppisljar Sep 15, 2016
b4da928
fixing some more tests
ppisljar Sep 15, 2016
93a5a96
fixing x-axis tests
ppisljar Sep 15, 2016
77f9cdc
fixing most of y-axis tests
ppisljar Sep 15, 2016
4ea7d29
fixing mismatches with current master
ppisljar Sep 16, 2016
c4709f6
fixing remaining tests
ppisljar Sep 16, 2016
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
53 changes: 42 additions & 11 deletions src/ui/public/vislib/__tests__/lib/axis_title.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import ngMock from 'ng_mock';
import expect from 'expect.js';
import $ from 'jquery';
import VislibLibAxisTitleProvider from 'ui/vislib/lib/axis_title';
import VislibLibAxisConfigProvider from 'ui/vislib/lib/axis_config';
import VislibLibDataProvider from 'ui/vislib/lib/data';
import PersistedStatePersistedStateProvider from 'ui/persisted_state/persisted_state';

describe('Vislib AxisTitle Class Test Suite', function () {
let AxisTitle;
let AxisConfig;
let Data;
let PersistedState;
let axisTitle;
Expand Down Expand Up @@ -79,27 +81,55 @@ describe('Vislib AxisTitle Class Test Suite', function () {
beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
AxisTitle = Private(VislibLibAxisTitleProvider);
AxisConfig = Private(VislibLibAxisConfigProvider);
Data = Private(VislibLibDataProvider);
PersistedState = Private(PersistedStatePersistedStateProvider);

el = d3.select('body').append('div')
.attr('class', 'vis-wrapper');

el.append('div')
.attr('class', 'y-axis-title')
.style('height', '20px')
.style('width', '20px');
.attr('class', 'axis-wrapper-bottom')
.append('div')
.attr('class', 'axis-title y-axis-title')
.style('height', '20px')
.style('width', '20px');

el.append('div')
.attr('class', 'x-axis-title')
.style('height', '20px')
.style('width', '20px');
.attr('class', 'axis-wrapper-left')
.append('div')
.attr('class', 'axis-title x-axis-title')
.style('height', '20px')
.style('width', '20px');


dataObj = new Data(data, {}, new PersistedState());
xTitle = dataObj.get('xAxisLabel');
yTitle = dataObj.get('yAxisLabel');
axisTitle = new AxisTitle($('.vis-wrapper')[0], xTitle, yTitle);
const xAxisConfig = new AxisConfig({
position: 'bottom',
title: {
text: dataObj.get('xAxisLabel')
},
vis: {
el: el.node(),
_attr: {
type: 'histogram'
}
}
});
const yAxisConfig = new AxisConfig({
position: 'left',
title: {
text: dataObj.get('yAxisLabel')
},
vis: {
el: el.node(),
_attr: {
type: 'histogram'
}
}
});
xTitle = new AxisTitle(xAxisConfig);
yTitle = new AxisTitle(yAxisConfig);
}));

afterEach(function () {
Expand All @@ -108,7 +138,8 @@ describe('Vislib AxisTitle Class Test Suite', function () {

describe('render Method', function () {
beforeEach(function () {
axisTitle.render();
xTitle.render();//here
yTitle.render();
});

it('should append an svg to div', function () {
Expand All @@ -129,7 +160,7 @@ describe('Vislib AxisTitle Class Test Suite', function () {

describe('draw Method', function () {
it('should be a function', function () {
expect(_.isFunction(axisTitle.draw())).to.be(true);
expect(_.isFunction(xTitle.draw())).to.be(true);
});
});

Expand Down
16 changes: 8 additions & 8 deletions src/ui/public/vislib/__tests__/lib/layout/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ dateHistogramArray.forEach(function (data, i) {
describe('createLayout Method', function () {
it('should append all the divs', function () {
expect($(vis.el).find('.vis-wrapper').length).to.be(1);
expect($(vis.el).find('.y-axis-col-wrapper').length).to.be(1);
expect($(vis.el).find('.y-axis-col-wrapper').length).to.be(2);
expect($(vis.el).find('.vis-col-wrapper').length).to.be(1);
expect($(vis.el).find('.y-axis-col').length).to.be(1);
expect($(vis.el).find('.y-axis-title').length).to.be(1);
expect($(vis.el).find('.y-axis-div-wrapper').length).to.be(1);
expect($(vis.el).find('.y-axis-spacer-block').length).to.be(1);
expect($(vis.el).find('.y-axis-col').length).to.be(2);
expect($(vis.el).find('.y-axis-title').length).to.be(2);
expect($(vis.el).find('.y-axis-div-wrapper').length).to.be(2);
expect($(vis.el).find('.y-axis-spacer-block').length).to.be(4);
expect($(vis.el).find('.chart-wrapper').length).to.be(numberOfCharts);
expect($(vis.el).find('.x-axis-wrapper').length).to.be(1);
expect($(vis.el).find('.x-axis-div-wrapper').length).to.be(1);
expect($(vis.el).find('.x-axis-title').length).to.be(1);
expect($(vis.el).find('.x-axis-wrapper').length).to.be(2);
expect($(vis.el).find('.x-axis-div-wrapper').length).to.be(2);
expect($(vis.el).find('.x-axis-title').length).to.be(2);
});
});

Expand Down
79 changes: 44 additions & 35 deletions src/ui/public/vislib/__tests__/lib/x_axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,16 @@ describe('Vislib xAxis Class Test Suite', function () {
dataObj = new Data(data, {}, persistedState);
xAxis = new Axis({
type: 'category',
el: $('.x-axis-div')[0],
xValues: dataObj.xValues(),
ordered: dataObj.get('ordered'),
xAxisFormatter: dataObj.get('xAxisFormatter'),
_attr: {
margin: { top: 0, right: 0, bottom: 0, left: 0 }
vis: {
el: $('.x-axis-div')[0],
_attr: {
margin: { top: 0, right: 0, bottom: 0, left: 0 },
type: 'histogram'
}
},
data: dataObj,
labels: {
xAxisFormatter: dataObj.get('xAxisFormatter')
}
});
}));
Expand Down Expand Up @@ -127,7 +131,7 @@ describe('Vislib xAxis Class Test Suite', function () {
});
});

describe('getScale, getDomain, getTimeDomain, getOrdinalDomain, and getRange Methods', function () {
describe('getScale, getDomain, getTimeDomain, and getRange Methods', function () {
let ordered;
let timeScale;
let timeDomain;
Expand All @@ -137,28 +141,45 @@ describe('Vislib xAxis Class Test Suite', function () {
let range;

beforeEach(function () {
timeScale = xAxis.getScale();
timeDomain = xAxis.getDomain(timeScale);
range = xAxis.getRange(timeDomain, width);
xAxis.ordered = {};
ordinalScale = xAxis.getScale();
ordinalDomain = ordinalScale.domain(['this', 'should', 'be', 'an', 'array']);
width = $('.x-axis-div').width();
xAxis.getAxis(width);
timeScale = xAxis.getScale();
timeDomain = xAxis.axisScale.getExtents();
range = xAxis.axisScale.getRange(width);
});

it('should return a function', function () {
expect(_.isFunction(timeScale)).to.be(true);
expect(_.isFunction(ordinalScale)).to.be(true);
});

it('should return the correct domain', function () {
expect(_.isDate(timeDomain.domain()[0])).to.be(true);
expect(_.isDate(timeDomain.domain()[1])).to.be(true);
expect(_.isDate(timeScale.domain()[0])).to.be(true);
expect(_.isDate(timeScale.domain()[1])).to.be(true);
});

it('should return the min and max dates', function () {
expect(timeDomain.domain()[0].toDateString()).to.be(new Date(1408734060000).toDateString());
expect(timeDomain.domain()[1].toDateString()).to.be(new Date(1408734330000).toDateString());
expect(timeScale.domain()[0].toDateString()).to.be(new Date(1408734060000).toDateString());
expect(timeScale.domain()[1].toDateString()).to.be(new Date(1408734330000).toDateString());
});

it('should return the correct range', function () {
expect(range[0]).to.be(0);
expect(range[1]).to.be(width);
});
});

describe('getOrdinalDomain Method', function () {
let ordinalScale;
let ordinalDomain;
let width;

beforeEach(function () {
width = $('.x-axis-div').width();
xAxis.ordered = null;
xAxis.config.ordered = null;
xAxis.getAxis(width);
ordinalScale = xAxis.getScale();
ordinalDomain = ordinalScale.domain(['this', 'should', 'be', 'an', 'array']);
});

it('should return an ordinal scale', function () {
Expand All @@ -169,11 +190,6 @@ describe('Vislib xAxis Class Test Suite', function () {
it('should return an array of values', function () {
expect(_.isArray(ordinalDomain.domain())).to.be(true);
});

it('should return the correct range', function () {
expect(range.range()[0]).to.be(0);
expect(range.range()[1]).to.be(width);
});
});

describe('getXScale Method', function () {
Expand All @@ -182,7 +198,8 @@ describe('Vislib xAxis Class Test Suite', function () {

beforeEach(function () {
width = $('.x-axis-div').width();
xScale = xAxis.getXScale(width);
xAxis.getAxis(width);
xScale = xAxis.getScale();
});

it('should return a function', function () {
Expand All @@ -206,19 +223,11 @@ describe('Vislib xAxis Class Test Suite', function () {

beforeEach(function () {
width = $('.x-axis-div').width();
xAxis.getXAxis(width);
});

it('should create an xAxis function on the xAxis class', function () {
expect(_.isFunction(xAxis.xAxis)).to.be(true);
});

it('should create an xScale function on the xAxis class', function () {
expect(_.isFunction(xAxis.xScale)).to.be(true);
xAxis.getAxis(width);
});

it('should create an xAxisFormatter function on the xAxis class', function () {
expect(_.isFunction(xAxis.axisFormatter)).to.be(true);
it('should create an getScale function on the xAxis class', function () {
expect(_.isFunction(xAxis.getScale())).to.be(true);
});
});

Expand Down
Loading