X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fhighlight_series_background.js;h=d2a09f0b329fd7c36cf448f60faad3a60353fc4d;hb=75ef32c911ae5ac3c454d6ae21afdde1e39a93bf;hp=aedc8edaf86ee2fcdd905dcda5008be44039a490;hpb=1715eee9eec72048d8fd94ce19127c330be3033e;p=dygraphs.git diff --git a/auto_tests/tests/highlight_series_background.js b/auto_tests/tests/highlight_series_background.js index aedc8ed..d2a09f0 100644 --- a/auto_tests/tests/highlight_series_background.js +++ b/auto_tests/tests/highlight_series_background.js @@ -1,18 +1,35 @@ /** - * @fileoverview Tests for the highlightSeriesBackgroundAlpha and highlightSeriesBackgroundColor options. + * @fileoverview Tests for the highlightSeriesBackgroundAlpha and + * highlightSeriesBackgroundColor options. * @author sergeyslepian@gmail.com */ +import Dygraph from '../../src/dygraph'; +import * as utils from '../../src/dygraph-utils'; +import Util from './Util'; + describe("highlight-series-background", function() { - beforeEach(function () { - document.body.innerHTML = "
"; + 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 () { + afterEach(function() { + utils.repeatAndCleanup = origRepeatAndCleanup; }); - function setupGraph(highlightSeriesBackgroundAlpha, highlightSeriesBackgroundColor) { + function setupGraph(highlightSeriesBackgroundAlpha, + highlightSeriesBackgroundColor) { var opts = { width: 480, height: 320, @@ -25,16 +42,15 @@ describe("highlight-series-background", function() { } }; - if(highlightSeriesBackgroundAlpha !== undefined) opts.highlightSeriesBackgroundAlpha = highlightSeriesBackgroundAlpha; - if(highlightSeriesBackgroundColor !== undefined) opts.highlightSeriesBackgroundColor = highlightSeriesBackgroundColor; + if (highlightSeriesBackgroundAlpha) utils.update(opts, {highlightSeriesBackgroundAlpha}); + if (highlightSeriesBackgroundColor) utils.update(opts, {highlightSeriesBackgroundColor}); var data = []; for (var j = 0; j < 10; j++) { data.push([j, 0]); } - var graph = document.getElementById("graph"); - return new Dygraph(graph, data, opts); + return new Dygraph('graph', data, opts); } it('testDefaultHighlight', function(done) { @@ -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,24 +75,24 @@ 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) { - var graph = setupGraph(undefined, 'rgb(0,255,255)'); + var graph = setupGraph(null, 'rgb(0,255,255)'); assert.deepEqual(Util.samplePixel(graph.canvas_, 100, 100), [0,0,0,0]); 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,9 @@ 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); }); -}); \ No newline at end of file +});