X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Frange_selector.js;h=82884c835e3a29ec665c8af100a31670f8bd78b5;hb=bedc5cd39283fe07b9e4125c4e397b14571fed15;hp=a8b9459ec77d909dfff81bb8ae0ce12005ac4294;hpb=44310217eccf34939b40cf0309b5a9b4e03df784;p=dygraphs.git diff --git a/auto_tests/tests/range_selector.js b/auto_tests/tests/range_selector.js index a8b9459..82884c8 100644 --- a/auto_tests/tests/range_selector.js +++ b/auto_tests/tests/range_selector.js @@ -4,13 +4,28 @@ * @fileoverview Regression tests for range selector. * @author paul.eric.felix@gmail.com (Paul Felix) */ + +import Dygraph from '../../src/dygraph'; +import * as utils from '../../src/dygraph-utils'; +import RangeSelectorPlugin from '../../src/plugins/range-selector'; + +import Util from './Util'; +import DygraphOps from './DygraphOps'; +import CanvasAssertions from './CanvasAssertions'; +import Proxy from './Proxy'; + describe("range-selector", function() { +cleanupAfterEach(); + +var restoreConsole; +var logs = {}; beforeEach(function() { - document.body.innerHTML = "
"; + restoreConsole = Util.captureConsole(logs); }); afterEach(function() { + restoreConsole(); }); it('testRangeSelector', function() { @@ -216,6 +231,10 @@ it('testRangeSelectorWithAnimatedZoomsOption', function() { var g = new Dygraph(graph, data, opts); assertGraphExistence(g, graph); assert.isFalse(g.getOption('animatedZooms')); + assert.deepEqual(logs, { + log: [], error: [], + warn: ["Animated zooms and range selector are not compatible; disabling animatedZooms."] + }); }); it('testRangeSelectorWithAnimatedZoomsOption2', function() { @@ -241,6 +260,10 @@ it('testRangeSelectorWithAnimatedZoomsOption2', function() { g.updateOptions({showRangeSelector: true}); assertGraphExistence(g, graph); assert.isFalse(g.getOption('animatedZooms')); + assert.deepEqual(logs, { + log: [], error: [], + warn: ["Animated zooms and range selector are not compatible; disabling animatedZooms."] + }); }); it('testRangeSelectorInteraction', function() { @@ -391,9 +414,9 @@ it('testRangeSelectorPositionIfXAxisNotDrawn', function() { it('testMiniPlotDrawn', function() { // Install Proxy to track canvas calls. - var origFunc = Dygraph.getContext; + var origFunc = utils.getContext; var miniHtx; - Dygraph.getContext = function(canvas) { + utils.getContext = function(canvas) { if (canvas.className != 'dygraph-rangesel-bgcanvas') { return origFunc(canvas); } @@ -423,7 +446,7 @@ it('testMiniPlotDrawn', function() { assert.isNotNull(miniHtx); assert.isTrue(0 < CanvasAssertions.numLinesDrawn(miniHtx, '#ff0000')); - Dygraph.getContext = origFunc; + utils.getContext = origFunc; }); // Tests data computation for the mini plot with a single series. @@ -440,7 +463,7 @@ it('testSingleCombinedSeries', function() { var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); - var rangeSelector = g.getPluginInstance_(Dygraph.Plugins.RangeSelector); + var rangeSelector = g.getPluginInstance_(RangeSelectorPlugin); assert.isNotNull(rangeSelector); var combinedSeries = rangeSelector.computeCombinedSeriesAndLimits_(); @@ -470,7 +493,7 @@ it('testCombinedSeries', function() { var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); - var rangeSelector = g.getPluginInstance_(Dygraph.Plugins.RangeSelector); + var rangeSelector = g.getPluginInstance_(RangeSelectorPlugin); assert.isNotNull(rangeSelector); var combinedSeries = rangeSelector.computeCombinedSeriesAndLimits_(); @@ -503,7 +526,7 @@ it('testSelectedCombinedSeries', function() { var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); - var rangeSelector = g.getPluginInstance_(Dygraph.Plugins.RangeSelector); + var rangeSelector = g.getPluginInstance_(RangeSelectorPlugin); assert.isNotNull(rangeSelector); var combinedSeries = rangeSelector.computeCombinedSeriesAndLimits_(); @@ -533,7 +556,7 @@ it('testSingleCombinedSeriesCustomBars', function() { var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); - var rangeSelector = g.getPluginInstance_(Dygraph.Plugins.RangeSelector); + var rangeSelector = g.getPluginInstance_(RangeSelectorPlugin); assert.isNotNull(rangeSelector); var combinedSeries = rangeSelector.computeCombinedSeriesAndLimits_(); @@ -562,7 +585,7 @@ it('testSingleCombinedSeriesErrorBars', function() { var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); - var rangeSelector = g.getPluginInstance_(Dygraph.Plugins.RangeSelector); + var rangeSelector = g.getPluginInstance_(RangeSelectorPlugin); assert.isNotNull(rangeSelector); var combinedSeries = rangeSelector.computeCombinedSeriesAndLimits_(); @@ -592,7 +615,7 @@ it('testTwoCombinedSeriesCustomBars', function() { var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); - var rangeSelector = g.getPluginInstance_(Dygraph.Plugins.RangeSelector); + var rangeSelector = g.getPluginInstance_(RangeSelectorPlugin); assert.isNotNull(rangeSelector); var combinedSeries = rangeSelector.computeCombinedSeriesAndLimits_();