X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;ds=sidebyside;f=auto_tests%2Ftests%2Fper_axis.js;h=d7f1a494d1eaaf69ebb71cd10a4fef7091489d9b;hb=b55a71d768d2f8de62877c32b3aec9e9975ac389;hp=a3bdbad7a2d0d05012e0db3c1259585c189412a7;hpb=319d0361d2e512ed8049dfedffd79254e491201c;p=dygraphs.git diff --git a/auto_tests/tests/per_axis.js b/auto_tests/tests/per_axis.js index a3bdbad..d7f1a49 100644 --- a/auto_tests/tests/per_axis.js +++ b/auto_tests/tests/per_axis.js @@ -3,21 +3,25 @@ * * @author konigsberg@google.com (Robert Konigsberg) */ -var perAxisTestCase = TestCase("per-axis"); -var _origGetContext = Dygraph.getContext; +import Dygraph from '../../src/dygraph'; +import * as utils from '../../src/dygraph-utils'; + +import Util from './Util'; +import CanvasAssertions from './CanvasAssertions'; +import Proxy from './Proxy'; + +describe("per-axis", function() { + +cleanupAfterEach(); +useProxyCanvas(utils, Proxy); var xAxisLineColor = "#00ffff"; var yAxisLineColor = "#ffff00"; var g, graph; -perAxisTestCase.prototype.setUp = function() { - document.body.innerHTML = "
"; - Dygraph.getContext = function(canvas) { - return new Proxy(_origGetContext(canvas)); - } - +beforeEach(function() { var opts = { axes : { x : { @@ -40,34 +44,32 @@ perAxisTestCase.prototype.setUp = function() { ; graph = document.getElementById('graph'); g = new Dygraph(graph, data, opts); -}; - -perAxisTestCase.prototype.tearDown = function() { - Dygraph.getContext = _origGetContext; -}; +}); -perAxisTestCase.prototype.testDrawXAxis = function() { +it('testDrawXAxis', function() { g.updateOptions({ axes : { x : { drawAxis: true }} }); - assertTrue(graph.getElementsByClassName('dygraph-axis-label-x').length > 0); - assertTrue(graph.getElementsByClassName('dygraph-axis-label-y').length == 0); -} + assert.isTrue(graph.getElementsByClassName('dygraph-axis-label-x').length > 0); + assert.isTrue(graph.getElementsByClassName('dygraph-axis-label-y').length == 0); +}); -perAxisTestCase.prototype.testDrawYAxis = function() { +it('testDrawYAxis', function() { g.updateOptions({ axes : { y : { drawAxis: true }} }); - assertTrue(graph.getElementsByClassName('dygraph-axis-label-x').length ==0); - assertTrue(graph.getElementsByClassName('dygraph-axis-label-y').length > 0); -} + assert.isTrue(graph.getElementsByClassName('dygraph-axis-label-x').length ==0); + assert.isTrue(graph.getElementsByClassName('dygraph-axis-label-y').length > 0); +}); -perAxisTestCase.prototype.testDrawXGrid = function() { +it('testDrawXGrid', function() { g.updateOptions({ axes : { x : { drawGrid : true }}}); var htx = g.hidden_ctx_; - assertTrue(CanvasAssertions.numLinesDrawn(htx, xAxisLineColor) > 0); - assertTrue(CanvasAssertions.numLinesDrawn(htx, yAxisLineColor) == 0); -} + assert.isTrue(CanvasAssertions.numLinesDrawn(htx, xAxisLineColor) > 0); + assert.isTrue(CanvasAssertions.numLinesDrawn(htx, yAxisLineColor) == 0); +}); -perAxisTestCase.prototype.testDrawYGrid = function() { +it('testDrawYGrid', function() { g.updateOptions({ axes : { y : { drawGrid : true }}}); var htx = g.hidden_ctx_; - assertTrue(CanvasAssertions.numLinesDrawn(htx, xAxisLineColor) == 0); - assertTrue(CanvasAssertions.numLinesDrawn(htx, yAxisLineColor) > 0); -} + assert.isTrue(CanvasAssertions.numLinesDrawn(htx, xAxisLineColor) == 0); + assert.isTrue(CanvasAssertions.numLinesDrawn(htx, yAxisLineColor) > 0); +}); + +});