X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fstacked.js;h=d9aadbf8aea33a8a1acf377105e6ea450f7e5d02;hb=ecdb6dffaa8111a807d1595f4051a594de91c613;hp=f7ca4428128550066b99e10e9e2c37c2255d1ed1;hpb=3bdeeb9b9d123e9e45159a6801b6e7fe74f08690;p=dygraphs.git diff --git a/auto_tests/tests/stacked.js b/auto_tests/tests/stacked.js index f7ca442..d9aadbf 100644 --- a/auto_tests/tests/stacked.js +++ b/auto_tests/tests/stacked.js @@ -78,11 +78,7 @@ stackedTestCase.prototype.testSelectionValues = function() { g.setSelection(0); - var legend = document.getElementsByClassName("dygraph-legend"); - assertEquals(1, legend.length); - legend = legend[0]; - - assertEquals("0: Y1:1 Y2:1", legend.textContent); + assertEquals("0: Y1: 1 Y2: 1", Util.getLegend()); // Verify that the behavior is correct with highlightSeriesOpts as well. g.updateOptions({ @@ -90,11 +86,38 @@ stackedTestCase.prototype.testSelectionValues = function() { strokeWidth: 10 } }); - // NOTE: calling g.setSelection(0) here makes the test fail, due to an - // unrelated bug. + g.setSelection(0); + assertEquals("0: Y1: 1 Y2: 1", Util.getLegend()); + g.setSelection(1); - assertEquals("1: Y1:1 Y2:1", legend.textContent); + assertEquals("1: Y1: 1 Y2: 1", Util.getLegend()); g.setSelection(0, 'Y2'); - assertEquals("0: Y1:1 Y2:1", legend.textContent); + assertEquals("0: Y1: 1 Y2: 1", Util.getLegend()); }; + +// Regression test for http://code.google.com/p/dygraphs/issues/detail?id=176 +stackedTestCase.prototype.testDuplicatedXValue = function() { + var opts = { + stackedGraph: true, + fillAlpha: 0.15, + colors: ['#00ff00'], + width: 400, + height: 300 + }; + var data = "X,Y1\n" + + "0,1\n" + + "1,1\n" + + "2,1\n" + + "2,1\n" + // duplicate x-value! + "3,1\n" + ; + + var graph = document.getElementById("graph"); + g = new Dygraph(graph, data, opts); + + assert(g.yAxisRange()[1] < 2); + + assertEquals([0, 255, 0, 38], Util.samplePixel(g.hidden_, 200, 250)); + assertEquals([0, 255, 0, 38], Util.samplePixel(g.hidden_, 317, 250)); +}