X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fper_series.js;h=a09f912c367e220e2c4c8ec10210b0cbe4de1215;hb=bf7d192b5aef6ea82e7e627d4cfcfca1cb978f23;hp=ab52addfdaa1cc2d27f091a6c755feac18cc3a27;hpb=21ebe38bb1eeae3a7fd73335a411bfd81c66d985;p=dygraphs.git diff --git a/auto_tests/tests/per_series.js b/auto_tests/tests/per_series.js index ab52add..a09f912 100644 --- a/auto_tests/tests/per_series.js +++ b/auto_tests/tests/per_series.js @@ -3,24 +3,32 @@ * * @author danvk@google.com (Dan Vanderkam) */ -var perSeriesTestCase = TestCase("per-series"); +describe("per-series", function() { -perSeriesTestCase.prototype.setUp = function() { +beforeEach(function() { document.body.innerHTML = "
"; -}; +}); -perSeriesTestCase.prototype.tearDown = function() { -}; +afterEach(function() { +}); -perSeriesTestCase.prototype.testPerSeriesFill = function() { +it('testPerSeriesFill', function() { var opts = { width: 480, height: 320, - drawXGrid: false, - drawYGrid: false, - drawXAxis: false, - drawYAxis: false, - Y: { fillGraph: true }, + axes : { + x : { + drawGrid: false, + drawAxis: false, + }, + y : { + drawGrid: false, + drawAxis: false, + } + }, + series: { + Y: { fillGraph: true }, + }, colors: [ '#FF0000', '#0000FF' ], fillAlpha: 0.15 }; @@ -36,72 +44,35 @@ perSeriesTestCase.prototype.testPerSeriesFill = function() { ; var graph = document.getElementById("graph"); - g = new Dygraph(graph, data, opts); + var g = new Dygraph(graph, data, opts); var sampler = new PixelSampler(g); // Inside of the "Z" bump -- no fill. - assertEquals([0,0,0,0], sampler.colorAtCoordinate(2.5, 0.5)); + assert.deepEqual([0,0,0,0], sampler.colorAtCoordinate(2.5, 0.5)); // Inside of the "Y" bump -- filled in. - assertEquals([255,0,0,38], sampler.colorAtCoordinate(6.5, 0.5)); -}; - -perSeriesTestCase.prototype.testOldStyleSeries = function() { - var opts = { - 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")); -}; + assert.deepEqual([255,0,0,38], sampler.colorAtCoordinate(6.5, 0.5)); +}); -perSeriesTestCase.prototype.testNewStyleSeriesTrumpsOldStyle = function() { +it('testNewStyleSeries', 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); - - assertEquals(5, g.getOption("pointSize")); - assertEquals(4, g.getOption("pointSize", "Y")); - assertEquals(5, g.getOption("pointSize", "Z")); + var g = new Dygraph(graph, data, opts); - // 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")); -}; + assert.equal(5, g.getOption("pointSize")); + assert.equal(4, g.getOption("pointSize", "Y")); + assert.equal(5, g.getOption("pointSize", "Z")); +}); // TODO(konigsberg): move to multiple_axes.js -perSeriesTestCase.prototype.testAxisInNewSeries = function() { +it('testAxisInNewSeries', function() { var opts = { series : { D : { axis : 'y2' }, @@ -112,14 +83,14 @@ perSeriesTestCase.prototype.testAxisInNewSeries = function() { }; var graph = document.getElementById("graph"); var data = "X,A,B,C,D,E\n0,1,2,3,4,5\n"; - g = new Dygraph(graph, data, opts); + var g = new Dygraph(graph, data, opts); - assertEquals(["A", "B", "E"], g.attributes_.seriesForAxis(0)); - assertEquals(["C", "D"], g.attributes_.seriesForAxis(1)); -}; + assert.deepEqual(["A", "B", "E"], g.attributes_.seriesForAxis(0)); + assert.deepEqual(["C", "D"], g.attributes_.seriesForAxis(1)); +}); // TODO(konigsberg): move to multiple_axes.js -perSeriesTestCase.prototype.testAxisInNewSeries_withAxes = function() { +it('testAxisInNewSeries_withAxes', function() { var opts = { series : { D : { axis : 'y2' }, @@ -134,21 +105,21 @@ perSeriesTestCase.prototype.testAxisInNewSeries_withAxes = function() { }; var graph = document.getElementById("graph"); var data = "X,A,B,C,D,E\n0,1,2,3,4,5\n"; - g = new Dygraph(graph, data, opts); + var g = new Dygraph(graph, data, opts); - assertEquals(["A", "B", "E"], g.attributes_.seriesForAxis(0)); - assertEquals(["C", "D"], g.attributes_.seriesForAxis(1)); + assert.deepEqual(["A", "B", "E"], g.attributes_.seriesForAxis(0)); + assert.deepEqual(["C", "D"], g.attributes_.seriesForAxis(1)); - assertEquals(1.5, g.getOption("pointSize")); - assertEquals(7, g.getOption("pointSize", "A")); - assertEquals(7, g.getOption("pointSize", "B")); - assertEquals(6, g.getOption("pointSize", "C")); - assertEquals(6, g.getOption("pointSize", "D")); - assertEquals(7, g.getOption("pointSize", "E")); -}; + assert.equal(1.5, g.getOption("pointSize")); + assert.equal(7, g.getOption("pointSize", "A")); + assert.equal(7, g.getOption("pointSize", "B")); + assert.equal(6, g.getOption("pointSize", "C")); + assert.equal(6, g.getOption("pointSize", "D")); + assert.equal(7, g.getOption("pointSize", "E")); +}); // TODO(konigsberg): move to multiple_axes.js -perSeriesTestCase.prototype.testOldAxisSpecInNewSeriesThrows = function() { +it('testOldAxisSpecInNewSeriesThrows', function() { var opts = { series : { D : { axis : {} }, @@ -156,11 +127,23 @@ perSeriesTestCase.prototype.testOldAxisSpecInNewSeriesThrows = function() { }; var graph = document.getElementById("graph"); var data = "X,A,B,C,D,E\n0,1,2,3,4,5\n"; + var threw = false; try { new Dygraph(graph, data, opts); } catch(e) { - assertEquals( - "Using objects for axis specification is not supported inside the 'series' option.", - e); + threw = true; } -} + + assert.isTrue(threw); +}); + +it('testColorOption', function() { + var graph = document.getElementById("graph"); + var data = "X,A,B,C\n0,1,2,3\n"; + var g = new Dygraph(graph, data, {}); + assert.deepEqual(['rgb(64,128,0)', 'rgb(64,0,128)', 'rgb(0,128,128)'], g.getColors()); + g.updateOptions({series : { B : { color : 'purple' }}}); + assert.deepEqual(['rgb(64,128,0)', 'purple', 'rgb(0,128,128)'], g.getColors()); +}); + +});