X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fcss.js;h=b2b0010212cd2b4d8ebcace1ab88032e63d92851;hb=d0da31d021ee7a89b378182a60bf28f0873fc87b;hp=79b8910ef0daef76e84f34c28c9ae6df51662810;hpb=0cb9bd91af9cf5f15d8f27c17835e9bc82bab661;p=dygraphs.git diff --git a/auto_tests/tests/css.js b/auto_tests/tests/css.js index 79b8910..b2b0010 100644 --- a/auto_tests/tests/css.js +++ b/auto_tests/tests/css.js @@ -105,6 +105,64 @@ CssTestCase.prototype.testClassPixelSize = function() { assertEquals({width: 456, height: 345}, g.size()); }; +// An invisible chart div shouldn't produce an error. +CssTestCase.prototype.testInvisibleChart = function() { + document.body.innerHTML = + '
' + + '
' + + '
'; + var graph = document.getElementById("graph"); + g = new Dygraph(graph, CssTestCase.data, {}); +}; + +// An invisible chart div shouldn't produce an error. +CssTestCase.prototype.testInvisibleChartDate = function() { + document.body.innerHTML = + '
' + + '
' + + '
'; + var graph = document.getElementById("graph"); + g = new Dygraph(graph, + "Date,Y\n" + + "2010/01/01,100\n" + + "2010/02/01,200\n" + + "2010/03/01,300\n" + + "2010/04/01,400\n" + + "2010/05/01,300\n" + + "2010/06/01,100\n" + , {}); +}; + +// An invisible chart div that becomes visible. +CssTestCase.prototype.testInvisibleThenVisibleChart = function() { + document.body.innerHTML = + ''; + var graph = document.getElementById("graph"); + g = new Dygraph(graph, + "Date,Y\n" + + "2010/01/01,100\n" + + "2010/02/01,200\n" + + "2010/03/01,300\n" + + "2010/04/01,400\n" + + "2010/05/01,300\n" + + "2010/06/01,100\n" + , {}); + + // g.size() is undefined here (probably 0x0) + document.getElementById("x").style.display = ""; + + // This resize() call is annoying but essential. + // There are no DOM events to inform the dygraph that its div has changed size + // or visibility so we need to let it know ourselves. + g.resize(); + + assertEquals(640, graph.offsetWidth); + assertEquals(480, graph.offsetHeight); + assertEquals({width: 640, height: 480}, g.size()); +}; + // Verifies that a div resize gets picked up. /* this one isn't quite ready yet.