X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fper_axis.js;h=d7f1a494d1eaaf69ebb71cd10a4fef7091489d9b;hb=bedc5cd39283fe07b9e4125c4e397b14571fed15;hp=add852d038349304416b99eebe35bafef26bc40e;hpb=4dd02536f448228c14844004354c744bba6d45a2;p=dygraphs.git diff --git a/auto_tests/tests/per_axis.js b/auto_tests/tests/per_axis.js index add852d..d7f1a49 100644 --- a/auto_tests/tests/per_axis.js +++ b/auto_tests/tests/per_axis.js @@ -3,30 +3,36 @@ * * @author konigsberg@google.com (Robert Konigsberg) */ -var perAxisTestCase = TestCase("per-axis"); -perAxisTestCase._origGetContext = Dygraph.getContext; +import Dygraph from '../../src/dygraph'; +import * as utils from '../../src/dygraph-utils'; -perAxisTestCase.prototype.setUp = function() { - document.body.innerHTML = "
"; - Dygraph.getContext = function(canvas) { - return new Proxy(perAxisTestCase._origGetContext(canvas)); - } +import Util from './Util'; +import CanvasAssertions from './CanvasAssertions'; +import Proxy from './Proxy'; - this.xAxisLineColor = "#00ffff"; - this.yAxisLineColor = "#ffff00"; +describe("per-axis", function() { +cleanupAfterEach(); +useProxyCanvas(utils, Proxy); + +var xAxisLineColor = "#00ffff"; +var yAxisLineColor = "#ffff00"; + +var g, graph; + +beforeEach(function() { var opts = { axes : { x : { drawAxis : false, drawGrid : false, - gridLineColor : this.xAxisLineColor + gridLineColor : xAxisLineColor }, y : { drawAxis : false, drawGrid : false, - gridLineColor : this.yAxisLineColor + gridLineColor : yAxisLineColor } }, colors: [ '#ff0000', '#0000ff' ] @@ -36,61 +42,34 @@ perAxisTestCase.prototype.setUp = function() { "1,1,0\n" + "8,0,1\n" ; - this.graph = document.getElementById('graph'); - this.g = new Dygraph(this.graph, data, opts); -}; - -perAxisTestCase.prototype.tearDown = function() { - Dygraph.getContext = perAxisTestCase._origGetContext; -}; - -perAxisTestCase.prototype.testDrawXAxis = function() { - this.g.updateOptions({ drawXAxis : true }); - assertTrue(this.graph.getElementsByClassName('dygraph-axis-label-x').length > 0); - assertTrue(this.graph.getElementsByClassName('dygraph-axis-label-y').length == 0); -} - -perAxisTestCase.prototype.testDrawYAxis = function() { - this.g.updateOptions({ drawYAxis : true }); - assertTrue(this.graph.getElementsByClassName('dygraph-axis-label-x').length ==0); - assertTrue(this.graph.getElementsByClassName('dygraph-axis-label-y').length > 0); -} + graph = document.getElementById('graph'); + g = new Dygraph(graph, data, opts); +}); -perAxisTestCase.prototype.testDrawAxisX = function() { - this.g.updateOptions({ axes : { x : { drawAxis : true }}}); - assertTrue(this.graph.getElementsByClassName('dygraph-axis-label-x').length > 0); - assertTrue(this.graph.getElementsByClassName('dygraph-axis-label-y').length == 0); -} +it('testDrawXAxis', function() { + g.updateOptions({ axes : { x : { drawAxis: true }} }); + assert.isTrue(graph.getElementsByClassName('dygraph-axis-label-x').length > 0); + assert.isTrue(graph.getElementsByClassName('dygraph-axis-label-y').length == 0); +}); -perAxisTestCase.prototype.testDrawAxisY = function() { - this.g.updateOptions({ axes : { y : { drawAxis : true }}}); - assertTrue(this.graph.getElementsByClassName('dygraph-axis-label-x').length ==0); - assertTrue(this.graph.getElementsByClassName('dygraph-axis-label-y').length > 0); -} -perAxisTestCase.prototype.testDrawXGrid = function() { - this.g.updateOptions({ drawXGrid : true }); - var htx = this.g.hidden_ctx_; - assertTrue(CanvasAssertions.numLinesDrawn(htx, this.xAxisLineColor) > 0); - assertTrue(CanvasAssertions.numLinesDrawn(htx, this.yAxisLineColor) == 0); -} +it('testDrawYAxis', function() { + g.updateOptions({ axes : { y : { drawAxis: true }} }); + assert.isTrue(graph.getElementsByClassName('dygraph-axis-label-x').length ==0); + assert.isTrue(graph.getElementsByClassName('dygraph-axis-label-y').length > 0); +}); -perAxisTestCase.prototype.testDrawYGrid = function() { - this.g.updateOptions({ drawYGrid : true }); - var htx = this.g.hidden_ctx_; - assertTrue(CanvasAssertions.numLinesDrawn(htx, this.xAxisLineColor) == 0); - assertTrue(CanvasAssertions.numLinesDrawn(htx, this.yAxisLineColor) > 0); -} +it('testDrawXGrid', function() { + g.updateOptions({ axes : { x : { drawGrid : true }}}); + var htx = g.hidden_ctx_; + assert.isTrue(CanvasAssertions.numLinesDrawn(htx, xAxisLineColor) > 0); + assert.isTrue(CanvasAssertions.numLinesDrawn(htx, yAxisLineColor) == 0); +}); -perAxisTestCase.prototype.testDrawGridX = function() { - this.g.updateOptions({ axes : { x : { drawGrid : true }}}); - var htx = this.g.hidden_ctx_; - assertTrue(CanvasAssertions.numLinesDrawn(htx, this.xAxisLineColor) > 0); - assertTrue(CanvasAssertions.numLinesDrawn(htx, this.yAxisLineColor) == 0); -} +it('testDrawYGrid', function() { + g.updateOptions({ axes : { y : { drawGrid : true }}}); + var htx = g.hidden_ctx_; + assert.isTrue(CanvasAssertions.numLinesDrawn(htx, xAxisLineColor) == 0); + assert.isTrue(CanvasAssertions.numLinesDrawn(htx, yAxisLineColor) > 0); +}); -perAxisTestCase.prototype.testDrawGridY = function() { - this.g.updateOptions({ axes : { y : { drawGrid : true }}}); - var htx = this.g.hidden_ctx_; - assertTrue(CanvasAssertions.numLinesDrawn(htx, this.xAxisLineColor) == 0); - assertTrue(CanvasAssertions.numLinesDrawn(htx, this.yAxisLineColor) > 0); -} +});