Skip to content

Commit

Permalink
add negative values to the tests
Browse files Browse the repository at this point in the history
also make var naming more consistent
  • Loading branch information
w33ble committed Jun 5, 2015
1 parent c8dfb38 commit d84bd86
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions test/unit/specs/vislib/lib/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ define(function (require) {

var Data;
var dataSeries = require('vislib_fixtures/mock_data/date_histogram/_series');
var stackedDataSeries = require('vislib_fixtures/mock_data/stacked/_stacked');
var dataSeriesNeg = require('vislib_fixtures/mock_data/date_histogram/_series_neg');
var dataStacked = require('vislib_fixtures/mock_data/stacked/_stacked');

var seriesData = {
'label': '',
Expand Down Expand Up @@ -185,28 +186,32 @@ define(function (require) {

describe('getYMin method', function () {
var visData;
var stackedVisData;
var visDataNeg;
var visDataStacked;
var minValue = 4;
var stackedMinValue = 15;
var minValueNeg = -41;
var minValueStacked = 15;

beforeEach(function () {
visData = new Data(dataSeries, {});
stackedVisData = new Data(stackedDataSeries, { type: 'histogram' });
visDataNeg = new Data(dataSeriesNeg, {});
visDataStacked = new Data(dataStacked, { type: 'histogram' });
});

// 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 min value', function () {
expect(visData.getYMin()).to.be(minValue);
expect(stackedVisData.getYMin()).to.be(stackedMinValue);
expect(visDataNeg.getYMin()).to.be(minValueNeg);
expect(visDataStacked.getYMin()).to.be(minValueStacked);
});

it('should have a minimum date value that is greater than the max value within the date range', function () {
var series = _.pluck(visData.chartData(), 'series');
var stackedSeries = _.pluck(stackedVisData.chartData(), 'series');
var stackedSeries = _.pluck(visDataStacked.chartData(), 'series');
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);
expect(_.min(stackedSeries.values, function (d) { return d.x; })).to.be.greaterThan(minValueStacked);
});

it('allows passing a value getter for manipulating the values considered', function () {
Expand All @@ -218,28 +223,32 @@ define(function (require) {

describe('getYMax method', function () {
var visData;
var stackedVisData;
var visDataNeg;
var visDataStacked;
var maxValue = 41;
var stackedMaxValue = 115;
var maxValueNeg = -4;
var maxValueStacked = 115;

beforeEach(function () {
visData = new Data(dataSeries, {});
stackedVisData = new Data(stackedDataSeries, { type: 'histogram' });
visDataNeg = new Data(dataSeriesNeg, {});
visDataStacked = new Data(dataStacked, { type: 'histogram' });
});

// 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 min value', function () {
expect(visData.getYMax()).to.be(maxValue);
expect(stackedVisData.getYMax()).to.be(stackedMaxValue);
expect(visDataNeg.getYMax()).to.be(maxValueNeg);
expect(visDataStacked.getYMax()).to.be(maxValueStacked);
});

it('should have a minimum date value that is greater than the max value within the date range', function () {
var series = _.pluck(visData.chartData(), 'series');
var stackedSeries = _.pluck(stackedVisData.chartData(), 'series');
var stackedSeries = _.pluck(visDataStacked.chartData(), 'series');
expect(_.min(series, function (d) { return d.x; })).to.be.greaterThan(maxValue);
expect(_.min(stackedSeries, function (d) { return d.x; })).to.be.greaterThan(stackedMaxValue);
expect(_.min(stackedSeries, function (d) { return d.x; })).to.be.greaterThan(maxValueStacked);
});

it('allows passing a value getter for manipulating the values considered', function () {
Expand Down

0 comments on commit d84bd86

Please sign in to comment.