From b0d3471da0800f0fd5dadd1d852ab6d520a06a25 Mon Sep 17 00:00:00 2001 From: Robert Konigsberg Date: Thu, 13 Dec 2012 12:01:32 -0500 Subject: [PATCH] Add tests that break currently, but will pass when http://code.google.com/p/dygraphs/issues/detail?id=412 is fixed. (Log scale works again.) --- auto_tests/tests/axis_labels.js | 12 ++++++++++++ auto_tests/tests/range_tests.js | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/auto_tests/tests/axis_labels.js b/auto_tests/tests/axis_labels.js index 5c57fd6..a52030a 100644 --- a/auto_tests/tests/axis_labels.js +++ b/auto_tests/tests/axis_labels.js @@ -524,3 +524,15 @@ AxisLabelsTestCase.prototype.testLabelKMG2 = function() { ["0","256","512","768","1k","1.25k","1.5k","1.75k","2k"], Util.getYLabels()); }; + +/** + * Verify that log scale axis range is properly specified. + */ +AxisLabelsTestCase.prototype.testLogScale = function() { + var g = new Dygraph("graph", [[0, 5], [1, 1000]], { logscale : true }); + var nonEmptyLabels = Util.getYLabels().filter(function(x) { return x.length > 0; }); + assertEquals(["6","10","30","60","100","300","600","1000"], nonEmptyLabels); + + g.updateOptions({ logscale : false }); + assertEquals(['0','200','400','600','800','1000'], Util.getYLabels()); +} diff --git a/auto_tests/tests/range_tests.js b/auto_tests/tests/range_tests.js index c92c489..bc333f9 100644 --- a/auto_tests/tests/range_tests.js +++ b/auto_tests/tests/range_tests.js @@ -35,6 +35,9 @@ var ZERO_TO_FIFTY_STEPS = function() { } return a; } (); +var FIVE_TO_ONE_THOUSAND = [ + [ 1, 10 ], [ 2, 20 ], [ 3, 30 ], [ 4, 40 ] , [ 5, 50 ], + [ 6, 60 ], [ 7, 70 ], [ 8, 80 ], [ 9, 90 ] , [ 10, 1000 ]]; var RangeTestCase = TestCase("range-tests"); @@ -136,3 +139,14 @@ RangeTestCase.prototype.testRestoreOriginalRanges_viaUpdateOptions = function() assertEquals([0, 55], g.yAxisRange(0)); assertEquals([10, 20], g.xAxisRange()); } + +/** + * Verify that log scale axis range is properly specified. + */ +RangeTestCase.prototype.testLogScaleExcludesZero = function() { + var g = new Dygraph("graph", FIVE_TO_ONE_THOUSAND, { logscale : true }); + assertEquals([10, 1099], g.yAxisRange(0)); + + g.updateOptions({ logscale : false }); + assertEquals([0, 1099], g.yAxisRange(0)); +} -- 2.7.4