X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Frange_selector.js;h=584e054a7dad55d42f78558162907c4c8ec231e5;hb=refs%2Fheads%2F558-fill-artifacts;hp=0c7c8dcfa697c13d7bd1143b146902c9693a237a;hpb=89fdcedbda6906d90e15d84285c4f6c0b8d96d28;p=dygraphs.git diff --git a/auto_tests/tests/range_selector.js b/auto_tests/tests/range_selector.js index 0c7c8dc..584e054 100644 --- a/auto_tests/tests/range_selector.js +++ b/auto_tests/tests/range_selector.js @@ -6,11 +6,15 @@ */ describe("range-selector", function() { +var restoreConsole; +var logs = {}; beforeEach(function() { document.body.innerHTML = "
"; + restoreConsole = Util.captureConsole(logs); }); afterEach(function() { + restoreConsole(); }); it('testRangeSelector', function() { @@ -183,8 +187,13 @@ it('testRangeSelectorEnablingAfterCreation', function() { ]; var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); + var initialChartHeight = g.getArea().h; g.updateOptions({showRangeSelector: true}); assertGraphExistence(g, graph); + assert(g.getArea().h < initialChartHeight); // range selector shown + + g.updateOptions({showRangeSelector: false}); + assert.equal(g.getArea().h, initialChartHeight); // range selector hidden }); // The animatedZooms option does not work with the range selector. Make sure it gets turned off. @@ -211,6 +220,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() { @@ -236,6 +249,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() { @@ -288,8 +305,8 @@ it('testRangeSelectorInteraction', function() { zoomhandles[0].dispatchEvent(mouseUpEvent); var newXRange = g.xAxisRange().slice(); - assert('left zoomhandle should have moved: '+newXRange[0]+'>'+xRange[0], newXRange[0] > xRange[0]); - assert.equal('right zoomhandle should not have moved', xRange[1], newXRange[1]); + assert(newXRange[0] > xRange[0], 'left zoomhandle should have moved: '+newXRange[0]+'>'+xRange[0]); + assert.equal(xRange[1], newXRange[1], 'right zoomhandle should not have moved'); // Move right zoomhandle in xRange = newXRange; @@ -318,8 +335,8 @@ it('testRangeSelectorInteraction', function() { zoomhandles[1].dispatchEvent(mouseUpEvent); var newXRange = g.xAxisRange().slice(); - assert('right zoomhandle should have moved: '+newXRange[1]+'<'+xRange[1], newXRange[1] < xRange[1]); - assert.equal('left zoomhandle should not have moved', xRange[0], newXRange[0]); + assert(newXRange[1] < xRange[1], 'right zoomhandle should have moved: '+newXRange[1]+'<'+xRange[1]); + assert.equal(xRange[0], newXRange[0], 'left zoomhandle should not have moved'); // Pan left xRange = newXRange; @@ -353,8 +370,8 @@ it('testRangeSelectorInteraction', function() { fgcanvas.dispatchEvent(mouseUpEvent); var newXRange = g.xAxisRange().slice(); - assert(newXRange[0]+'<'+xRange[0], newXRange[0] < xRange[0]); - assert(newXRange[1]+'<'+xRange[1], newXRange[1] < xRange[1]); + assert(newXRange[0] < xRange[0], newXRange[0]+'<'+xRange[0]); + assert(newXRange[1] < xRange[1], newXRange[1]+'<'+xRange[1]); }); @@ -379,9 +396,9 @@ it('testRangeSelectorPositionIfXAxisNotDrawn', function() { // xAxis shouldn't be reserved since it isn't drawn. assertGraphExistence(g, graph); var bgcanvas = graph.getElementsByClassName('dygraph-rangesel-bgcanvas')[0]; - assert.equal("Range selector is not at the expected position.","70px", bgcanvas.style.top); + assert.equal("70px", bgcanvas.style.top, "Range selector is not at the expected position."); var fgcanvas = graph.getElementsByClassName('dygraph-rangesel-fgcanvas')[0]; - assert.equal("Range selector is not at the expected position.","70px", fgcanvas.style.top); + assert.equal("70px", fgcanvas.style.top, "Range selector is not at the expected position."); }); it('testMiniPlotDrawn', function() { @@ -389,7 +406,6 @@ it('testMiniPlotDrawn', function() { var origFunc = Dygraph.getContext; var miniHtx; Dygraph.getContext = function(canvas) { - console.log(canvas.className); if (canvas.className != 'dygraph-rangesel-bgcanvas') { return origFunc(canvas); }