X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fgrid_per_axis.js;fp=auto_tests%2Ftests%2Fgrid_per_axis.js;h=580bf2f630c07f1a826c686803e69efa692ee988;hb=89fdcedbda6906d90e15d84285c4f6c0b8d96d28;hp=3173cf3d617736ee6a705616d84d81a33fd1bed9;hpb=319d0361d2e512ed8049dfedffd79254e491201c;p=dygraphs.git diff --git a/auto_tests/tests/grid_per_axis.js b/auto_tests/tests/grid_per_axis.js index 3173cf3..580bf2f 100644 --- a/auto_tests/tests/grid_per_axis.js +++ b/auto_tests/tests/grid_per_axis.js @@ -4,26 +4,26 @@ * * @author david.eberlein@ch.sauter-bc.com (Fr. Sauter AG) */ -var GridPerAxisTestCase = TestCase("grid-per-axis"); +describe("grid-per-axis", function() { -GridPerAxisTestCase.prototype.setUp = function() { +beforeEach(function() { document.body.innerHTML = "
"; -}; +}); var origFunc = Dygraph.getContext; -GridPerAxisTestCase.prototype.setUp = function() { +beforeEach(function() { document.body.innerHTML = "
"; Dygraph.getContext = function(canvas) { return new Proxy(origFunc(canvas)); }; -}; +}); -GridPerAxisTestCase.prototype.tearDown = function() { +afterEach(function() { Dygraph.getContext = origFunc; -}; +}); -GridPerAxisTestCase.prototype.testIndependentGrids = function() { +it('testIndependentGrids', function() { var opts = { width : 480, height : 320, @@ -50,7 +50,7 @@ GridPerAxisTestCase.prototype.testIndependentGrids = function() { var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); - htx = g.hidden_ctx_; + var htx = g.hidden_ctx_; // The expected gridlines var yGridlines = [ 0, 20, 40, 60, 80, 100, 120 ]; @@ -72,7 +72,7 @@ GridPerAxisTestCase.prototype.testIndependentGrids = function() { for ( var i = 0; i < gridlines[axis].length; i++) { // Check the labels: var labels = Util.getYLabels(axis + 1); - assertEquals("Expected label not found.", gridlines[axis][i], labels[i]); + assert.equal("Expected label not found.", gridlines[axis][i], labels[i]); // Check that the grid was drawn. y = halfDown(g.toDomYCoord(gridlines[axis][i], axis)); @@ -81,9 +81,9 @@ GridPerAxisTestCase.prototype.testIndependentGrids = function() { CanvasAssertions.assertLineDrawn(htx, p1, p2, attrs); } } -}; +}); -GridPerAxisTestCase.prototype.testPerAxisGridColors = function() { +it('testPerAxisGridColors', function() { var opts = { width : 480, height : 320, @@ -114,7 +114,7 @@ GridPerAxisTestCase.prototype.testPerAxisGridColors = function() { [ 5, 110, 333 ] ]; var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); - htx = g.hidden_ctx_; + var htx = g.hidden_ctx_; // The expected gridlines var yGridlines = [ 20, 40, 60, 80, 100, 120 ]; @@ -136,12 +136,12 @@ GridPerAxisTestCase.prototype.testPerAxisGridColors = function() { for ( var i = 0; i < gridlines[axis].length; i++) { y = halfDown(g.toDomYCoord(gridlines[axis][i], axis)); // Check the grid colors. - assertEquals("Unexpected grid color found at pixel: x: " + x + "y: " + y, + assert.equal("Unexpected grid color found at pixel: x: " + x + "y: " + y, gridColors[axis], Util.samplePixel(g.hidden_, x, y)); } } -}; -GridPerAxisTestCase.prototype.testPerAxisGridWidth = function() { +}); +it('testPerAxisGridWidth', function() { var opts = { width : 480, height : 320, @@ -174,7 +174,7 @@ GridPerAxisTestCase.prototype.testPerAxisGridWidth = function() { [ 5, 110, 333 ] ]; var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); - htx = g.hidden_ctx_; + var htx = g.hidden_ctx_; // The expected gridlines var yGridlines = [ 20, 40, 60, 80 ]; @@ -208,23 +208,23 @@ GridPerAxisTestCase.prototype.testPerAxisGridWidth = function() { // Check the grid width. switch (axis) { case 0: // y with 2 pixels width - assertEquals("Unexpected y-grid color found at pixel: x: " + x + "y: " + assert.equal("Unexpected y-grid color found at pixel: x: " + x + "y: " + y, emptyColor, drawnPixeldown2); - assertEquals("Unexpected y-grid color found at pixel: x: " + x + "y: " + assert.equal("Unexpected y-grid color found at pixel: x: " + x + "y: " + y, gridColor, drawnPixeldown1); - assertEquals("Unexpected y-grid color found at pixel: x: " + x + "y: " + assert.equal("Unexpected y-grid color found at pixel: x: " + x + "y: " + y, gridColor, drawnPixel); - assertEquals("Unexpected y-grid color found at pixel: x: " + x + "y: " + assert.equal("Unexpected y-grid color found at pixel: x: " + x + "y: " + y, gridColor, drawnPixelup1); - assertEquals("Unexpected y-grid color found at pixel: x: " + x + "y: " + assert.equal("Unexpected y-grid color found at pixel: x: " + x + "y: " + y, emptyColor, drawnPixelup2); break; case 1: // y2 with 1 pixel width - assertEquals("Unexpected y2-grid color found at pixel: x: " + x + "y: " + assert.equal("Unexpected y2-grid color found at pixel: x: " + x + "y: " + y, emptyColor, drawnPixeldown1); - assertEquals("Unexpected y2-grid color found at pixel: x: " + x + "y: " + assert.equal("Unexpected y2-grid color found at pixel: x: " + x + "y: " + y, gridColor, drawnPixel); - assertEquals("Unexpected y2-grid color found at pixel: x: " + x + "y: " + assert.equal("Unexpected y2-grid color found at pixel: x: " + x + "y: " + y, emptyColor, drawnPixelup1); break; } @@ -235,24 +235,24 @@ GridPerAxisTestCase.prototype.testPerAxisGridWidth = function() { y = halfDown(g.plotter_.area.y) + 10; for ( var i = 0; i < xGridlines.length; i++) { x = halfUp(g.toDomXCoord(xGridlines[i])); - assertEquals("Unexpected x-grid color found at pixel: x: " + x + "y: " + y, + assert.equal("Unexpected x-grid color found at pixel: x: " + x + "y: " + y, emptyColor, Util.samplePixel(g.hidden_, x - 4, y).slice(0, 3)); - assertEquals("Unexpected x-grid color found at pixel: x: " + x + "y: " + y, + assert.equal("Unexpected x-grid color found at pixel: x: " + x + "y: " + y, gridColor, Util.samplePixel(g.hidden_, x - 3, y).slice(0, 3)); - assertEquals("Unexpected x-grid color found at pixel: x: " + x + "y: " + y, + assert.equal("Unexpected x-grid color found at pixel: x: " + x + "y: " + y, gridColor, Util.samplePixel(g.hidden_, x - 2, y).slice(0, 3)); - assertEquals("Unexpected x-grid color found at pixel: x: " + x + "y: " + y, + assert.equal("Unexpected x-grid color found at pixel: x: " + x + "y: " + y, gridColor, Util.samplePixel(g.hidden_, x - 1, y).slice(0, 3)); - assertEquals("Unexpected x-grid color found at pixel: x: " + x + "y: " + y, + assert.equal("Unexpected x-grid color found at pixel: x: " + x + "y: " + y, gridColor, Util.samplePixel(g.hidden_, x, y).slice(0, 3)); - assertEquals("Unexpected x-grid color found at pixel: x: " + x + "y: " + y, + assert.equal("Unexpected x-grid color found at pixel: x: " + x + "y: " + y, gridColor, Util.samplePixel(g.hidden_, x + 1, y).slice(0, 3)); - assertEquals("Unexpected x-grid color found at pixel: x: " + x + "y: " + y, + assert.equal("Unexpected x-grid color found at pixel: x: " + x + "y: " + y, emptyColor, Util.samplePixel(g.hidden_, x + 2, y).slice(0, 3)); } -}; +}); -GridPerAxisTestCase.prototype.testGridLinePattern = function() { +it('testGridLinePattern', function() { var opts = { width : 120, height : 320, @@ -283,7 +283,7 @@ GridPerAxisTestCase.prototype.testGridLinePattern = function() { [ 5, 110, 333 ] ]; var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); - htx = g.hidden_ctx_; + var htx = g.hidden_ctx_; // The expected gridlines var yGridlines = [ 0, 20, 40, 60, 80, 100, 120 ]; @@ -309,14 +309,16 @@ GridPerAxisTestCase.prototype.testGridLinePattern = function() { var pattern = (Math.floor((x) / 10)) % 2; switch (pattern) { case 0: // fill - assertEquals("Unexpected filled grid-pattern color found at pixel: x: " + x + " y: " + assert.equal("Unexpected filled grid-pattern color found at pixel: x: " + x + " y: " + y, [ 0, 0, 255 ], drawnPixel); break; case 1: // no fill - assertEquals("Unexpected empty grid-pattern color found at pixel: x: " + x + " y: " + assert.equal("Unexpected empty grid-pattern color found at pixel: x: " + x + " y: " + y, [ 0, 0, 0 ], drawnPixel); break; } } } -}; +}); + +});