From: Jan Tagscherer <3198913+jtagscherer@users.noreply.github.com> Date: Wed, 14 Nov 2018 10:12:57 +0000 (+0100) Subject: Add regression test for legend layout issue (#5776) X-Git-Tag: v2.8.0-rc.1~114 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3ea93a09f2047b727891f9e13dbd3fb7ebe44adf;p=thirdparty%2FChart.js.git Add regression test for legend layout issue (#5776) --- diff --git a/test/specs/plugin.legend.tests.js b/test/specs/plugin.legend.tests.js index 924276587..b6bb1a894 100644 --- a/test/specs/plugin.legend.tests.js +++ b/test/specs/plugin.legend.tests.js @@ -525,6 +525,43 @@ describe('Legend block tests', function() { }); }); + it('should not draw legend items outside of the chart bounds', function() { + var chart = window.acquireChart( + { + type: 'line', + data: { + datasets: [1, 2, 3].map(function(n) { + return { + label: 'dataset' + n, + data: [] + }; + }), + labels: [] + }, + options: { + legend: { + position: 'right' + } + } + }, + { + canvas: { + width: 512, + height: 105 + } + } + ); + + // Check some basic assertions about the test setup + expect(chart.width).toBe(512); + expect(chart.legend.legendHitBoxes.length).toBe(3); + + // Check whether any legend items reach outside the established bounds + chart.legend.legendHitBoxes.forEach(function(item) { + expect(item.left + item.width).toBeLessThanOrEqual(chart.width); + }); + }); + describe('config update', function() { it ('should update the options', function() { var chart = acquireChart({