]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Tests for suggestedMin and suggestedMax options 1586/head
authorEvert Timberg <evert.timberg@gmail.com>
Sat, 31 Oct 2015 15:40:51 +0000 (11:40 -0400)
committerEvert Timberg <evert.timberg@gmail.com>
Sat, 31 Oct 2015 15:40:51 +0000 (11:40 -0400)
test/scale.linear.tests.js

index 2906d641b2604946f0f5dfb56b3e4cac49add52b..4da804266e1fce39766c4f05dc10b8f9b6055483 100644 (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';