X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fper_series.js;h=a09f912c367e220e2c4c8ec10210b0cbe4de1215;hb=2ef8997fe939afdfd7c2c09c393a3073897633bd;hp=8a7e081f66d55670a38d6a889ff15398fcf65d98;hpb=c17e11738cb5603fafcdc84527114502312344c4;p=dygraphs.git diff --git a/auto_tests/tests/per_series.js b/auto_tests/tests/per_series.js index 8a7e081..a09f912 100644 --- a/auto_tests/tests/per_series.js +++ b/auto_tests/tests/per_series.js @@ -3,23 +3,29 @@ * * @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, + axes : { + x : { + drawGrid: false, + drawAxis: false, + }, + y : { + drawGrid: false, + drawAxis: false, + } + }, series: { Y: { fillGraph: true }, }, @@ -38,32 +44,18 @@ 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)); -}; + assert.deepEqual([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() { +it('testNewStyleSeries', function() { var opts = { pointSize : 5, series : { @@ -72,38 +64,15 @@ perSeriesTestCase.prototype.testNewStyleSeries = function() { }; var graph = document.getElementById("graph"); var data = "X,Y,Z\n1,0,0\n"; - g = new Dygraph(graph, data, opts); + var 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); - - 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")); -}; + 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' }, @@ -114,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' }, @@ -136,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 : {} }, @@ -165,14 +134,16 @@ perSeriesTestCase.prototype.testOldAxisSpecInNewSeriesThrows = function() { threw = true; } - assertTrue(threw); -} + assert.isTrue(threw); +}); -perSeriesTestCase.prototype.testColorOption = function() { +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, {}); - assertEquals(['rgb(64,128,0)', 'rgb(64,0,128)', 'rgb(0,128,128)'], g.getColors()); + assert.deepEqual(['rgb(64,128,0)', 'rgb(64,0,128)', 'rgb(0,128,128)'], g.getColors()); g.updateOptions({series : { B : { color : 'purple' }}}); - assertEquals(['rgb(64,128,0)', 'purple', 'rgb(0,128,128)'], g.getColors()); -} + assert.deepEqual(['rgb(64,128,0)', 'purple', 'rgb(0,128,128)'], g.getColors()); +}); + +});