add test for appending aggConfig to point data

This commit is contained in:
Joe Fleming 2015-09-18 11:38:34 -07:00
parent 619730298b
commit 4a3673ee1b

View file

@ -14,61 +14,79 @@ describe('getPoint', function () {
getPoint = Private(require('ui/agg_response/point_series/_get_point'));
}));
it('properly unwraps and scales values without a series', function () {
var row = [ { value: 1 }, { value: 2 }, { value: 3 } ];
var xAspect = { i: 0 };
var seriesAspect = null;
var yScale = 5;
var yAspect = { i: 1 };
var zAspect = { i: 2 };
var point = getPoint(xAspect, seriesAspect, yScale, row, yAspect, zAspect);
describe('Without series aspect', function () {
var seriesAspect;
var xAspect;
var yAspect;
var yScale;
expect(point)
.to.have.property('x', 1)
.and.have.property('y', 10)
.and.have.property('z', 3)
.and.have.property('aggConfigResult', row[1])
.and.not.have.property('series');
beforeEach(function () {
seriesAspect = null;
xAspect = { i: 0 };
yAspect = { i: 1 };
yScale = 5;
});
it('properly unwraps and scales values', function () {
var row = [ { value: 1 }, { value: 2 }, { value: 3 } ];
var zAspect = { i: 2 };
var point = getPoint(xAspect, seriesAspect, yScale, row, yAspect, zAspect);
expect(point)
.to.have.property('x', 1)
.and.have.property('y', 10)
.and.have.property('z', 3)
.and.have.property('aggConfigResult', row[1])
.and.not.have.property('series');
});
it('ignores points with a y value of NaN', function () {
var row = [ { value: 1 }, { value: 'NaN' }];
var point = getPoint(xAspect, seriesAspect, yScale, row, yAspect);
expect(point).to.be(void 0);
});
});
it('properly unwraps and scales values with a series', function () {
var row = [ { value: 1 }, { value: 2 }, { value: 3 }];
var xAspect = { i: 0 };
var seriesAspect = { i: 1, agg: identFormatted };
var yScale = null;
var yAspect = { i: 2 };
var point = getPoint(xAspect, seriesAspect, yScale, row, yAspect);
describe('With series aspect', function () {
var row;
var xAspect;
var yAspect;
var yScale;
expect(point)
.to.have.property('x', 1)
.and.have.property('series', 2)
.and.have.property('y', 3)
.and.have.property('aggConfigResult', row[2]);
beforeEach(function () {
row = [ { value: 1 }, { value: 2 }, { value: 3 }];
xAspect = { i: 0 };
yAspect = { i: 2 };
yScale = null;
});
it('properly unwraps and scales values', function () {
var seriesAspect = { i: 1, agg: identFormatted };
var point = getPoint(xAspect, seriesAspect, yScale, row, yAspect);
expect(point)
.to.have.property('x', 1)
.and.have.property('series', 2)
.and.have.property('y', 3)
.and.have.property('aggConfigResult', row[2]);
});
it('properly formats series values', function () {
var seriesAspect = { i: 1, agg: truthFormatted };
var point = getPoint(xAspect, seriesAspect, yScale, row, yAspect);
expect(point)
.to.have.property('x', 1)
.and.have.property('series', true)
.and.have.property('y', 3)
.and.have.property('aggConfigResult', row[2]);
});
it ('adds the aggConfig to the points', function () {
var seriesAspect = { i: 1, agg: truthFormatted};
var point = getPoint(xAspect, seriesAspect, yScale, row, yAspect);
expect(point).to.have.property('aggConfig', truthFormatted);
});
});
it('properly formats series values', function () {
var row = [ { value: 1 }, { value: 2 }, { value: 3 } ];
var xAspect = { i: 0 };
var seriesAspect = { i: 1, agg: truthFormatted };
var yScale = null;
var yAspect = { i: 2 };
var point = getPoint(xAspect, seriesAspect, yScale, row, yAspect);
expect(point)
.to.have.property('x', 1)
.and.have.property('series', true)
.and.have.property('y', 3)
.and.have.property('aggConfigResult', row[2]);
});
it('ignores points with a y value of NaN', function () {
var row = [ { value: 1 }, { value: 'NaN' }];
var xAspect = { i: 0 };
var seriesAspect = null;
var yScale = 5;
var yAspect = { i: 1 };
var point = getPoint(xAspect, seriesAspect, yScale, row, yAspect);
expect(point).to.be(void 0);
});
});