mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
adding tests for xAxis and yAxis constructors
This commit is contained in:
parent
31e5db290b
commit
e8891c5a33
4 changed files with 31 additions and 18 deletions
|
@ -19,10 +19,6 @@ define(function (require) {
|
|||
d3.select(this.el).selectAll('.x-axis-div').call(this.draw());
|
||||
};
|
||||
|
||||
XAxis.prototype.removeAll = function () {
|
||||
return d3.select(this.el).selectAll('.x-axis-div').selectAll('*').remove();
|
||||
};
|
||||
|
||||
XAxis.prototype.getScale = function (ordered) {
|
||||
if (ordered && ordered.date) {
|
||||
return d3.time.scale();
|
||||
|
|
|
@ -103,8 +103,9 @@ define(function (require) {
|
|||
});
|
||||
|
||||
describe('render Method', function () {
|
||||
beforeEach(function () {
|
||||
beforeEach(function (done) {
|
||||
chart.render(data);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should bind data to this object', function () {
|
||||
|
|
|
@ -123,7 +123,7 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
describe('getScale, getDomain, and getRange Methods', function () {
|
||||
describe('getScale, getDomain, getTimeDomain, getOrdinalDomain, and getRange Methods', function () {
|
||||
var ordered;
|
||||
var timeScale;
|
||||
var timeDomain;
|
||||
|
@ -152,11 +152,20 @@ define(function (require) {
|
|||
expect(_.isDate(timeDomain.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());
|
||||
});
|
||||
|
||||
it('should return an ordinal scale', function () {
|
||||
expect(ordinalDomain.domain()[0]).to.be('this');
|
||||
expect(ordinalDomain.domain()[4]).to.be('array');
|
||||
});
|
||||
|
||||
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);
|
||||
|
|
|
@ -194,18 +194,17 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
// describe('getYStackMax Method', function () {
|
||||
// it('should return the max value of a series array', function () {
|
||||
// expect(typeof yAxis._attr.stack).to.be('function');
|
||||
// expect(yAxis.getYStackMax(data.series[0].values)).to.be(36);
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// describe('getYMaxValue Method', function () {
|
||||
// it('should return the data max y value', function () {
|
||||
// expect(yAxis.getYMaxValue()).to.be(36);
|
||||
// });
|
||||
// });
|
||||
describe('getYStackMax Method', function () {
|
||||
it('should return the max value of a series array', function () {
|
||||
expect(yAxis.getYStackMax(yAxis.dataArray[0])).to.be(72);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getYMaxValue Method', function () {
|
||||
it('should return the data max y value', function () {
|
||||
expect(yAxis.getYMaxValue()).to.be(72);
|
||||
});
|
||||
});
|
||||
|
||||
describe('draw Method', function () {
|
||||
it('should be a function', function () {
|
||||
|
@ -213,5 +212,13 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
describe('tickScale Method', function () {
|
||||
it('should return the correct number of ticks', function () {
|
||||
expect(yAxis.tickScale(1000)).to.be(11);
|
||||
expect(yAxis.tickScale(40)).to.be(3);
|
||||
expect(yAxis.tickScale(20)).to.be(0);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue