X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fhighlight_series_background.js;h=abf0d6a6bcbabf9197f5af4b494674f29eb6501d;hb=7454418463735d68643ee25f112ec2e8288b859c;hp=60f4f8d1722452520def2e7875a340101466f3fb;hpb=6833c463ec383edd9dd4051b7a4cb8de834e27d0;p=dygraphs.git diff --git a/auto_tests/tests/highlight_series_background.js b/auto_tests/tests/highlight_series_background.js index 60f4f8d..abf0d6a 100644 --- a/auto_tests/tests/highlight_series_background.js +++ b/auto_tests/tests/highlight_series_background.js @@ -12,6 +12,22 @@ describe("highlight-series-background", function() { cleanupAfterEach(); + var origRepeatAndCleanup; + + beforeEach(function() { + // A "fast" version of repeatAndCleanup + origRepeatAndCleanup = utils.repeatAndCleanup; + // utils.repeatAndCleanup = function(repeatFn, maxFrames, framePeriodInMillis, cleanupFn) { + // repeatFn(0); + // if (maxFrames > 1) repeatFn(maxFrames - 1); + // cleanupFn(); + // }; + }); + + afterEach(function() { + utils.repeatAndCleanup = origRepeatAndCleanup; + }); + function setupGraph(highlightSeriesBackgroundAlpha, highlightSeriesBackgroundColor) { var opts = { @@ -45,10 +61,10 @@ describe("highlight-series-background", function() { graph.setSelection(0, 'y', true); // handle background color fade-in time - setTimeout(function() { + window.setTimeout(() => { assert.deepEqual(Util.samplePixel(graph.canvas_, 100, 100), [255,255,255,127]); done(); - }, 1000); + }, 500); }); it('testNoHighlight', function(done) { @@ -59,10 +75,10 @@ describe("highlight-series-background", function() { graph.setSelection(0, 'y', true); // handle background color fade-in time - setTimeout(function() { + window.setTimeout(() => { assert.deepEqual(Util.samplePixel(graph.canvas_, 100, 100), [0,0,0,0]); done(); - }, 1000); + }, 500); }); it('testCustomHighlightColor', function(done) { @@ -73,10 +89,10 @@ describe("highlight-series-background", function() { graph.setSelection(0, 'y', true); // handle background color fade-in time - setTimeout(function() { + window.setTimeout(() => { assert.deepEqual(Util.samplePixel(graph.canvas_, 100, 100), [0,255,255,127]); done(); - }, 1000); + }, 500); }); it('testCustomHighlightAlpha', function(done) { @@ -87,10 +103,10 @@ describe("highlight-series-background", function() { graph.setSelection(0, 'y', true); // handle background color fade-in time - setTimeout(function() { + window.setTimeout(() => { assert.deepEqual(Util.samplePixel(graph.canvas_, 100, 100), [255,255,255,179]); done(); - }, 1000); + }, 500); }); it('testCustomHighlightColorAndAlpha', function(done) { @@ -101,9 +117,34 @@ describe("highlight-series-background", function() { graph.setSelection(0, 'y', true); // handle background color fade-in time - setTimeout(function() { + window.setTimeout(() => { assert.deepEqual(Util.samplePixel(graph.canvas_, 100, 100), [255,0,0,76]); done(); - }, 1000); + }, 500); + }); + + it('testGetSelectionZeroCanvasY', function () { + var graph = document.getElementById("graph"); + var calls = [] + function callback(g, seriesName, canvasContext, cx, cy, color, pointSize, idx) { + calls.push(arguments); + }; + + var g = new Dygraph(document.getElementById("graph"), + "X,Y\n" + + "1,5\n" + + "1,10\n" + + "1,12\n", + { + drawHighlightPointCallback: callback, + axes: { + y: { + valueRange: [0, 10] + } + } + }); + g.setSelection(1); + var args = calls[0]; + assert.equal(args[4], 0); }); });