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=124d929bcc38fa5ff8012f76cbdcdc9e5cc10e41;hb=77a1405a7dea7e9de770583598a50e5907e6b1a1;hp=9d5df4653b282d63d2f1c3bc4e9a803eff530a13;hpb=9d79fed952e57cd7cd675a2eb30fdf2ce2665cdc;p=dygraphs.git diff --git a/auto_tests/tests/plugins_legend.js b/auto_tests/tests/plugins_legend.js index 9d5df46..124d929 100644 --- a/auto_tests/tests/plugins_legend.js +++ b/auto_tests/tests/plugins_legend.js @@ -1,12 +1,7 @@ -/** - * @fileoverview FILL THIS IN - * - * @author akiya.mizukoshi@gmail.com (Akiyah) - */ describe("plugins-legend", function() { beforeEach(function() { - document.body.innerHTML = "
"; + document.body.innerHTML = "
"; }); afterEach(function() { @@ -45,4 +40,35 @@ 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'}); +null + g.setSelection(0); + assert.equal('1: Y: 2', Util.nbspToSpace(labelsDiv.textContent)); +}); + +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 }); + 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', { + strokePattern: [5, 5], + color: 'red', + legend: 'always' + }); + + // The legend has a dashed line and a label. + var legendEl = document.querySelector('.dygraph-legend > span'); + assert.equal(' Y', legendEl.textContent); + var dashEl = document.querySelector('.dygraph-legend > span > div'); + assert.equal(window.getComputedStyle(dashEl)['border-bottom-color'], + 'rgb(255, 0, 0)'); +}); + });