Skip to content

Commit

Permalink
Add regression test for legend layout issue chartjs#5491
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Tagscherer committed Nov 12, 2018
1 parent e730f87 commit a4da36a
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/specs/plugin.legend.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit a4da36a

Please sign in to comment.