From: Robert Konigsberg Date: Thu, 22 Nov 2012 19:03:30 +0000 (-0500) Subject: Add per-series tests that validate new-style options and how they relate to old-style... X-Git-Tag: v1.0.0~157^2~7 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=0fe209e5342738d306be0edc4bc1cd381fec5baf;p=dygraphs.git Add per-series tests that validate new-style options and how they relate to old-style options. --- diff --git a/auto_tests/tests/per_series.js b/auto_tests/tests/per_series.js index 63fa8c2..a198a95 100644 --- a/auto_tests/tests/per_series.js +++ b/auto_tests/tests/per_series.js @@ -53,11 +53,51 @@ perSeriesTestCase.prototype.testOldStyleSeries = function() { pointSize : 5, Y: { pointSize : 4 }, }; + var graph = document.getElementById("graph"); + var data = "X,Y,Z\n1,0,0\n"; + g = new Dygraph(graph, data, opts); + + assertEquals(5, g.getOption("pointSize")); + assertEquals(4, g.getOption("pointSize", "Y")); + assertEquals(5, g.getOption("pointSize", "Z")); +}; + +perSeriesTestCase.prototype.testNewStyleSeries = function() { + var opts = { + pointSize : 5, + series : { + Y: { pointSize : 4 } + }, + }; + var graph = document.getElementById("graph"); + var data = "X,Y,Z\n1,0,0\n"; + g = new Dygraph(graph, data, opts); + + assertEquals(5, g.getOption("pointSize")); + assertEquals(4, g.getOption("pointSize", "Y")); + assertEquals(5, g.getOption("pointSize", "Z")); +}; + +perSeriesTestCase.prototype.testNewStyleSeriesTrumpsOldStyle = function() { + var opts = { + pointSize : 5, + Z : { pointSize : 6 }, + series : { + Y: { pointSize : 4 } + }, + }; + var graph = document.getElementById("graph"); var data = "X,Y,Z\n1,0,0\n"; - g = new Dygraph("Graph", data, opts); + g = new Dygraph(graph, data, opts); assertEquals(5, g.getOption("pointSize")); assertEquals(4, g.getOption("pointSize", "Y")); assertEquals(5, g.getOption("pointSize", "Z")); + + // Erase the series object, and Z will become visible again. + g.updateOptions({ series : undefined }); + assertEquals(5, g.getOption("pointSize")); + assertEquals(6, g.getOption("pointSize", "Z")); + assertEquals(5, g.getOption("pointSize", "Y")); };