mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
[vislib/yAxis] added tests for the tickLabel method
This commit is contained in:
parent
0a7596149c
commit
ff3e5bc399
1 changed files with 42 additions and 8 deletions
|
@ -6,6 +6,7 @@ define(function (require) {
|
|||
var YAxis;
|
||||
var Data;
|
||||
var el;
|
||||
var buildYAxis;
|
||||
var yAxis;
|
||||
var yAxisDiv;
|
||||
|
||||
|
@ -70,14 +71,18 @@ define(function (require) {
|
|||
defaultYMin: true
|
||||
});
|
||||
|
||||
yAxis = new YAxis({
|
||||
el: node,
|
||||
yMin: dataObj.getYMin(),
|
||||
yMax: dataObj.getYMax(),
|
||||
_attr: {
|
||||
margin: { top: 0, right: 0, bottom: 0, left: 0 }
|
||||
}
|
||||
});
|
||||
buildYAxis = function (params) {
|
||||
return new YAxis(_.merge({}, params, {
|
||||
el: node,
|
||||
yMin: dataObj.getYMin(),
|
||||
yMax: dataObj.getYMax(),
|
||||
_attr: {
|
||||
margin: { top: 0, right: 0, bottom: 0, left: 0 }
|
||||
}
|
||||
}));
|
||||
};
|
||||
|
||||
yAxis = buildYAxis();
|
||||
}
|
||||
|
||||
describe('Vislib yAxis Class Test Suite', function () {
|
||||
|
@ -346,5 +351,34 @@ define(function (require) {
|
|||
expect(yAxis.tickScale(20)).to.be(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#tickFormat()', function () {
|
||||
var formatter = function () {};
|
||||
|
||||
it('returns a basic number formatter by default', function () {
|
||||
var yAxis = buildYAxis();
|
||||
expect(yAxis.tickFormat()).to.not.be(formatter);
|
||||
expect(yAxis.tickFormat()(1)).to.be('1');
|
||||
});
|
||||
|
||||
it('returns the yAxisFormatter when passed', function () {
|
||||
var yAxis = buildYAxis({
|
||||
yAxisFormatter: formatter
|
||||
});
|
||||
expect(yAxis.tickFormat()).to.be(formatter);
|
||||
});
|
||||
|
||||
it('returns a percentage formatter when the vis is in percentage mode', function () {
|
||||
var yAxis = buildYAxis({
|
||||
yAxisFormatter: formatter,
|
||||
_attr: {
|
||||
mode: 'percentage'
|
||||
}
|
||||
});
|
||||
|
||||
expect(yAxis.tickFormat()).to.not.be(formatter);
|
||||
expect(yAxis.tickFormat()(1)).to.be('100%');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue