X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fplugins_legend.js;fp=auto_tests%2Ftests%2Fplugins_legend.js;h=26daf926e012c2688e98e4076368c42918f3558b;hb=e8c70e4e0f4c124a2c68eb43d6ec4e781d1bf810;hp=124d929bcc38fa5ff8012f76cbdcdc9e5cc10e41;hpb=6ecc073934b76e5076f917112a24ff7094857730;p=dygraphs.git diff --git a/auto_tests/tests/plugins_legend.js b/auto_tests/tests/plugins_legend.js index 124d929..26daf92 100644 --- a/auto_tests/tests/plugins_legend.js +++ b/auto_tests/tests/plugins_legend.js @@ -1,10 +1,16 @@ +import Dygraph from '../../src/dygraph'; +import LegendPlugin from '../../src/plugins/legend'; +import Util from './Util'; + describe("plugins-legend", function() { -beforeEach(function() { - document.body.innerHTML = "
"; -}); +var graph; -afterEach(function() { +cleanupAfterEach(); +beforeEach(function() { + var testDiv = document.getElementById('graph'); + testDiv.innerHTML = "
"; + graph = document.getElementById('inner-graph'); }); it('testLegendEscape', function() { @@ -19,10 +25,9 @@ it('testLegendEscape', function() { "3,0\n" ; - var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); - var legendPlugin = new Dygraph.Plugins.Legend(); + var legendPlugin = new LegendPlugin(); legendPlugin.activate(g); var e = { selectedX: 'selectedX', @@ -42,7 +47,7 @@ it('testLegendEscape', function() { it('should let labelsDiv be a string', function() { var labelsDiv = document.getElementById('label'); - var g = new Dygraph('graph', 'X,Y\n1,2\n', {labelsDiv: 'label'}); + var g = new Dygraph(graph, 'X,Y\n1,2\n', {labelsDiv: 'label'}); null g.setSelection(0); assert.equal('1: Y: 2', Util.nbspToSpace(labelsDiv.textContent)); @@ -50,14 +55,14 @@ null it('should let labelsDiv be an Element', function() { var labelsDiv = document.getElementById('label'); - var g = new Dygraph('graph', 'X,Y\n1,2\n', { labelsDiv: labelsDiv }); + var g = new Dygraph(graph, 'X,Y\n1,2\n', { labelsDiv: labelsDiv }); assert.isNull(labelsDiv.getAttribute('class')); // dygraph-legend not added. g.setSelection(0); assert.equal('1: Y: 2', Util.nbspToSpace(labelsDiv.textContent)); }); it('should render dashed patterns', function() { - var g = new Dygraph('graph', 'X,Y\n1,2\n', { + var g = new Dygraph(graph, 'X,Y\n1,2\n', { strokePattern: [5, 5], color: 'red', legend: 'always'