From: manufitoussi Date: Fri, 25 Jan 2013 14:36:48 +0000 (+0100) Subject: Adding test for the per axis option includeZero X-Git-Tag: v1.0.0~105^2~9 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=c387c823906347553a25da22383c1741989f2eaf;p=dygraphs.git Adding test for the per axis option includeZero --- diff --git a/auto_tests/tests/range_tests.js b/auto_tests/tests/range_tests.js index c2ef95e..767206f 100644 --- a/auto_tests/tests/range_tests.js +++ b/auto_tests/tests/range_tests.js @@ -162,6 +162,84 @@ RangeTestCase.prototype.testIncludeZeroIncludesZero = function() { assertEquals([450, 1050], g.yAxisRange(0)); } + +/** + * Verify that includeZero range is properly specified per axis. + */ +RangeTestCase.prototype.testIncludeZeroPerAxis = function() { + var g = new Dygraph("graph", + 'X,A,B\n'+ + '0,50,50\n'+ + '50,110,110\n', + { + drawPoints: true, + pointSize:5, + series:{ + A: { + axis: 'y', + pointSize: 10 + }, + B: { + axis: 'y2' + } + }, + axes: { + 'y2': { includeZero: true } + } + }); + + + assertEquals([44, 116], g.yAxisRange(0)); + assertEquals([0, 121], g.yAxisRange(1)); + + g.updateOptions({ + axes: { + 'y2': { includeZero: false } + } + }); + + assertEquals([44, 116], g.yAxisRange(1)); +} + + +/** + * Verify that includeZero range is properly specified per axis with old axis options. + */ +RangeTestCase.prototype.testIncludeZeroPerAxisOld = function() { + var g = new Dygraph("graph", + 'X,A,B\n' + + '0,50,50\n' + + '50,110,110\n', + { + drawPoints: true, + pointSize: 5, + + A: { + pointSize: 10 + }, + B: { + axis: {} + }, + axes: { + 'y': { includeZero: true }, + 'y2': { includeZero: false } + } + }); + + assertEquals([0, 121], g.yAxisRange(0)); + assertEquals([44, 116], g.yAxisRange(1)); + + g.updateOptions({ + axes: { + 'y': { includeZero: false }, + 'y2': { includeZero: true } + } + }); + + assertEquals([44, 116], g.yAxisRange(0)); + assertEquals([0, 121], g.yAxisRange(1)); +} + /** * Verify that very large Y ranges don't break things. */