X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fto_dom_coords.js;h=454050115bb6af37fef85f740ac2a9bcb6969997;hb=ce31caf22475e3e1fd6d9fea192d61ff4fcd7fac;hp=abbe332112697bb962cbe4acaf43e015c6465632;hpb=dc910fcebc0da0a621cf16073ebedabcff32fb12;p=dygraphs.git diff --git a/auto_tests/tests/to_dom_coords.js b/auto_tests/tests/to_dom_coords.js index abbe332..4540501 100644 --- a/auto_tests/tests/to_dom_coords.js +++ b/auto_tests/tests/to_dom_coords.js @@ -3,20 +3,17 @@ * * @author danvk@google.com (Dan Vanderkam) */ +import Dygraph from '../../src/dygraph'; +import * as utils from '../../src/dygraph-utils'; -describe("to-dom-coords", function() { +import Proxy from './Proxy'; +import CanvasAssertions from './CanvasAssertions'; +import {assertDeepCloseTo} from './custom_asserts'; -var origFunc = Dygraph.getContext; -beforeEach(function() { - document.body.innerHTML = "
"; - Dygraph.getContext = function(canvas) { - return new Proxy(origFunc(canvas)); - } -}); +describe("to-dom-coords", function() { -afterEach(function() { - Dygraph.getContext = origFunc; -}); +cleanupAfterEach(); +useProxyCanvas(utils, Proxy); // Checks that toDomCoords and toDataCoords are inverses of one another. var checkForInverses = function(g) { @@ -34,14 +31,14 @@ var checkForInverses = function(g) { it('testPlainChart', function() { var opts = { - axes : { - x : { + axes: { + x: { drawAxis : false, - drawGrid : false, + drawGrid : false }, - y : { + y: { drawAxis : false, - drawGrid : false, + drawGrid : false } }, rightGap: 0, @@ -49,7 +46,8 @@ it('testPlainChart', function() { dateWindow: [0, 100], width: 400, height: 400, - colors: ['#ff0000'] + colors: ['#ff0000'], + labels: ['X', 'Y'] } var graph = document.getElementById("graph"); @@ -69,12 +67,12 @@ it('testPlainChart', function() { it('testChartWithAxes', function() { var opts = { - axes : { - x : { + axes: { + x: { drawGrid: false, drawAxis: true, }, - y : { + y: { drawGrid: false, drawAxis: true, axisLabelWidth: 100 @@ -87,7 +85,8 @@ it('testChartWithAxes', function() { dateWindow: [0, 100], width: 500, height: 450, - colors: ['#ff0000'] + colors: ['#ff0000'], + labels: ['X', 'Y'] } var graph = document.getElementById("graph"); @@ -103,16 +102,16 @@ it('testChartWithAxes', function() { it('testChartWithAxesAndLabels', function() { var opts = { - axes : { - x : { + axes: { + x: { drawGrid: false, drawAxis: true, }, - y : { + y: { drawGrid: false, drawAxis: true, axisLabelWidth: 100 - } + }, }, xAxisHeight: 50, axisTickSize: 0, @@ -126,7 +125,8 @@ it('testChartWithAxesAndLabels', function() { xlabel: 'This is the x-axis', xLabelHeight: 25, title: 'This is the title of the chart', - titleHeight: 25 + titleHeight: 25, + labels: ['X', 'Y'] } var graph = document.getElementById("graph"); @@ -148,7 +148,8 @@ it('testYAxisLabelWidth', function() { valueRange: [0, 100], dateWindow: [0, 100], width: 500, - height: 500 + height: 500, + labels: ['X', 'Y'] } var graph = document.getElementById("graph"); @@ -172,7 +173,8 @@ it('testAxisTickSize', function() { valueRange: [0, 100], dateWindow: [0, 100], width: 500, - height: 500 + height: 500, + labels: ['X', 'Y'] } var graph = document.getElementById("graph"); @@ -204,7 +206,8 @@ it('testChartLogarithmic_YAxis', function() { drawAxis: false, logscale: true } - } + }, + labels: ['X', 'Y'] } var graph = document.getElementById("graph"); @@ -242,7 +245,8 @@ it('testChartLogarithmic_XAxis', function() { drawGrid: false, drawAxis: false } - } + }, + labels: ['X', 'Y'] } var graph = document.getElementById("graph");