Tests for suggestedMin and suggestedMax options

This commit is contained in:
Evert Timberg 2015-10-31 11:40:51 -04:00
parent 3aaa3e27f3
commit 07b052cfab

View File

@ -283,6 +283,37 @@ describe('Linear Scale', function() {
expect(scale.max).toBe(1);
});
it('Should use the suggestedMin and suggestedMax options', function() {
var scaleID = 'myScale';
var mockData = {
datasets: [{
yAxisID: scaleID,
data: [1, 1, 1, 2, 1, 0]
}]
};
var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear'));
config.ticks.suggestedMin = -10;
config.ticks.suggestedMax = 10;
var Constructor = Chart.scaleService.getScaleConstructor('linear');
var scale = new Constructor({
ctx: {},
options: config,
data: mockData,
id: scaleID
});
// Set arbitrary width and height for now
scale.width = 50;
scale.height = 400;
scale.buildTicks();
expect(scale.min).toBe(-10);
expect(scale.max).toBe(10);
});
it('should forcibly include 0 in the range if the beginAtZero option is used', function() {
var scaleID = 'myScale';