[vislib/data] update tests
This commit is contained in:
parent
c7aaddc3cf
commit
c3232bec68
|
@ -230,21 +230,26 @@ define(function (require) {
|
|||
colOut = colIn.flatten();
|
||||
});
|
||||
|
||||
it('should return an array of arrays', function () {
|
||||
expect(_.isArray(serOut)).to.be(true);
|
||||
it('should return an array of value objects from every series', function () {
|
||||
expect(serOut.every(_.isObject)).to.be(true);
|
||||
});
|
||||
|
||||
it('should return array length 3', function () {
|
||||
expect(serOut[0][0].length).to.be(3);
|
||||
});
|
||||
function testLength(inputData) {
|
||||
return function () {
|
||||
var data = new dataFactory(inputData, {});
|
||||
var len = _.reduce(data.chartData(), function (sum, chart) {
|
||||
return sum + chart.series.reduce(function (sum, series) {
|
||||
return sum + series.values.length;
|
||||
}, 0);
|
||||
}, 0);
|
||||
|
||||
it('should return array length 3', function () {
|
||||
expect(rowOut[0][0].length).to.be(3);
|
||||
});
|
||||
expect(data.flatten()).to.have.length(len);
|
||||
};
|
||||
}
|
||||
|
||||
it('should return array length 3', function () {
|
||||
expect(colOut[0][0].length).to.be(3);
|
||||
});
|
||||
it('should return all points from every series', testLength(seriesData));
|
||||
it('should return all points from every series', testLength(rowsData));
|
||||
it('should return all points from every series', testLength(colsData));
|
||||
});
|
||||
|
||||
describe('getYMinValue method', function () {
|
||||
|
@ -269,8 +274,8 @@ define(function (require) {
|
|||
stackedDataSeries = require('vislib_fixtures/mock_data/stacked/_stacked');
|
||||
visData = new Data(dataSeries, {});
|
||||
stackedVisData = new Data(stackedDataSeries, {});
|
||||
series = visData.flatten();
|
||||
stackedSeries = stackedVisData.flatten();
|
||||
series = _.pluck(visData.chartData(), 'series');
|
||||
stackedSeries = _.pluck(stackedVisData.chartData(), 'series');
|
||||
minValue = 4;
|
||||
stackedMinValue = 15;
|
||||
});
|
||||
|
@ -280,26 +285,13 @@ define(function (require) {
|
|||
// date range. It also has the largest y value. This value should be excluded
|
||||
// when calculating the Y max value since it falls outside of the range.
|
||||
it('should return the Y domain min value', function () {
|
||||
series.forEach(function (data) {
|
||||
if (!visData.shouldBeStacked(data)) {
|
||||
expect(visData.getYMinValue()).to.be(minValue);
|
||||
} else {
|
||||
expect(visData.getYMinValue()).to.be(stackedMinValue);
|
||||
}
|
||||
});
|
||||
|
||||
series.forEach(function (data) {
|
||||
expect(visData._getYExtent(data, visData._getY, 'min')).to.be(minValue);
|
||||
});
|
||||
|
||||
stackedSeries.forEach(function (data) {
|
||||
expect(stackedVisData._getYExtent(data, visData._getYStack, 'min')).to.be(stackedMinValue);
|
||||
});
|
||||
expect(visData.getYMinValue()).to.be(minValue);
|
||||
expect(stackedSeries.getYMinValue()).to.be(stackedMinValue);
|
||||
});
|
||||
|
||||
it('should have a minimum date value that is greater than the max value within the date range', function () {
|
||||
expect(_.min(series, function (d) { return d.x; })).to.be.greaterThan(minValue);
|
||||
expect(_.min(stackedSeries, function (d) { return d.x; })).to.be.greaterThan(stackedMinValue);
|
||||
expect(_.min(series.values, function (d) { return d.x; })).to.be.greaterThan(minValue);
|
||||
expect(_.min(stackedSeries.values, function (d) { return d.x; })).to.be.greaterThan(stackedMinValue);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -325,23 +317,19 @@ define(function (require) {
|
|||
stackedDataSeries = require('vislib_fixtures/mock_data/stacked/_stacked');
|
||||
visData = new Data(dataSeries, {});
|
||||
stackedVisData = new Data(stackedDataSeries, {});
|
||||
series = visData.flatten();
|
||||
stackedSeries = stackedVisData.flatten();
|
||||
series = _.pluck(visData.chartData(), 'series');
|
||||
stackedSeries = _.pluck(stackedVisData.chartData(), 'series');
|
||||
maxValue = 41;
|
||||
stackedMaxValue = 115;
|
||||
stackedMaxValue = 110;
|
||||
});
|
||||
});
|
||||
|
||||
// The first value in the time series is less than the min date in the
|
||||
// date range. It also has the largest y value. This value should be excluded
|
||||
// when calculating the Y max value since it falls outside of the range.
|
||||
it('should return the Y domain max value', function () {
|
||||
series.forEach(function (data) {
|
||||
expect(visData._getYExtent(data, visData._getY, 'max')).to.be(maxValue);
|
||||
});
|
||||
stackedSeries.forEach(function (data) {
|
||||
expect(stackedVisData._getYExtent(data, visData._getYStack, 'max')).to.be(stackedMaxValue);
|
||||
});
|
||||
it('should return the Y domain min value', function () {
|
||||
expect(visData.getYMaxValue()).to.be(maxValue);
|
||||
expect(stackedVisData.getYMaxValue()).to.be(stackedMaxValue);
|
||||
});
|
||||
|
||||
it('should have a minimum date value that is greater than the max value within the date range', function () {
|
||||
|
|
Loading…
Reference in a new issue