X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fcustom_bars.js;h=ebc867a38a29732c48064c6dbc0879c5660045d6;hb=93ec1094eb75477b455efaa7adeb10190b87992b;hp=1107c9e5ef8b100ed2eea3a20e0ba4fad073041f;hpb=89fdcedbda6906d90e15d84285c4f6c0b8d96d28;p=dygraphs.git diff --git a/auto_tests/tests/custom_bars.js b/auto_tests/tests/custom_bars.js index 1107c9e..ebc867a 100644 --- a/auto_tests/tests/custom_bars.js +++ b/auto_tests/tests/custom_bars.js @@ -4,18 +4,25 @@ * @fileoverview Regression test based on some strange customBars data. * @author danvk@google.com (Dan Vanderkam) */ +import Dygraph from '../../src/dygraph'; +import * as utils from '../../src/dygraph-utils'; +import CanvasAssertions from './CanvasAssertions'; +import PixelSampler from './PixelSampler'; +import Proxy from './Proxy'; + describe("custom-bars", function() { -var _origFunc = Dygraph.getContext; +cleanupAfterEach(); + +var _origFunc = utils.getContext; beforeEach(function() { - document.body.innerHTML = "
"; - Dygraph.getContext = function(canvas) { + utils.getContext = function(canvas) { return new Proxy(_origFunc(canvas)); } }); afterEach(function() { - Dygraph.getContext = _origFunc; + utils.getContext = _origFunc; }); // This test used to reliably produce an infinite loop. @@ -77,8 +84,8 @@ it('testCustomBarsZero', function() { var g = new Dygraph(graph, data, opts); var range = g.yAxisRange(); - assert.isTrue('y-axis must include 0', range[0] <= 0); - assert.isTrue('y-axis must include 5', range[1] >= 5); + assert.isTrue(range[0] <= 0, 'y-axis must include 0'); + assert.isTrue(range[1] >= 5, 'y-axis must include 5'); }); // Regression test for http://code.google.com/p/dygraphs/issues/detail?id=229 @@ -99,19 +106,20 @@ it('testCustomBarsAtTop', function() { width: 500, height: 350, customBars: true, errorBars: true, - axes : { - x : { + axes: { + x: { drawGrid: false, drawAxis: false, }, - y : { + y: { drawGrid: false, drawAxis: false, } }, valueRange: [0, 120], fillAlpha: 0.15, - colors: [ '#00FF00' ] + colors: ['#00FF00'], + labels: ['X', 'Y'] }); var sampler = new PixelSampler(g); @@ -142,7 +150,8 @@ it('testCustomBarsLogScale', function() { }, fillAlpha: 1.0, logscale: true, - colors: [ '#00FF00' ] + colors: ['#00FF00'], + labels: ['X', 'Y'] }); // The following assertions describe the sides of the custom bars, which are @@ -180,8 +189,9 @@ it('testCustomBarsWithNegativeValuesInLogScale', function() { ], { drawPoints: true, - drawPointCallback : drawPointCallback, - customBars: true + drawPointCallback: drawPointCallback, + customBars: true, + labels: ['X', 'Y'] }); // Normally all three points would be drawn.