Skip to content

Commit

Permalink
Use empty labels for tests so as not to be affected by the font width
Browse files Browse the repository at this point in the history
  • Loading branch information
nagix committed Nov 19, 2018
1 parent ecf64d3 commit d91e821
Showing 1 changed file with 49 additions and 46 deletions.
95 changes: 49 additions & 46 deletions test/specs/plugin.legend.tests.js
Expand Up @@ -181,19 +181,19 @@ describe('Legend block tests', function() {
type: 'bar',
data: {
datasets: [{
label: 'dataset1',
label: '',
backgroundColor: '#f31',
borderCapStyle: 'butt',
borderDash: [2, 2],
borderDashOffset: 5.5,
data: []
}, {
label: 'dataset2',
label: '',
hidden: true,
borderJoinStyle: 'miter',
data: []
}, {
label: 'dataset3',
label: '',
borderWidth: 10,
borderColor: 'green',
data: []
Expand All @@ -205,9 +205,9 @@ describe('Legend block tests', function() {
expect(chart.legend.legendHitBoxes.length).toBe(3);

[
{h: 12, l: 107, t: 10, w: 93},
{h: 12, l: 210, t: 10, w: 93},
{h: 12, l: 312, t: 10, w: 93}
{h: 12, l: 177, t: 10, w: 46},
{h: 12, l: 233, t: 10, w: 46},
{h: 12, l: 289, t: 10, w: 46}
].forEach(function(expected, i) {
expect(chart.legend.legendHitBoxes[i].height).toBeCloseToPixel(expected.h);
expect(chart.legend.legendHitBoxes[i].left).toBeCloseToPixel(expected.l);
Expand Down Expand Up @@ -394,19 +394,19 @@ describe('Legend block tests', function() {
type: 'bar',
data: {
datasets: [{
label: 'dataset1',
label: '',
backgroundColor: '#f31',
borderCapStyle: 'butt',
borderDash: [2, 2],
borderDashOffset: 5.5,
data: []
}, {
label: 'dataset2',
label: '',
hidden: true,
borderJoinStyle: 'miter',
data: []
}, {
label: 'dataset3',
label: '',
borderWidth: 10,
borderColor: 'green',
data: []
Expand All @@ -423,9 +423,9 @@ describe('Legend block tests', function() {
expect(chart.legend.legendHitBoxes.length).toBe(3);

[
{h: 12, l: 10, t: 16, w: 93},
{h: 12, l: 10, t: 38, w: 93},
{h: 12, l: 10, t: 60, w: 93}
{h: 12, l: 10, t: 16, w: 46},
{h: 12, l: 10, t: 38, w: 46},
{h: 12, l: 10, t: 60, w: 46}
].forEach(function(expected, i) {
expect(chart.legend.legendHitBoxes[i].height).toBeCloseToPixel(expected.h);
expect(chart.legend.legendHitBoxes[i].left).toBeCloseToPixel(expected.l);
Expand All @@ -438,9 +438,9 @@ describe('Legend block tests', function() {
var chart = window.acquireChart({
type: 'bar',
data: {
datasets: [1, 2, 3, 4, 5].map(function(n) {
datasets: Array.apply(null, Array(9)).map(function() {
return {
label: 'dataset' + n,
label: '',
data: []
};
}),
Expand All @@ -452,15 +452,18 @@ describe('Legend block tests', function() {
expect(chart.legend.top).toBeCloseToPixel(0);
expect(chart.legend.width).toBeCloseToPixel(512);
expect(chart.legend.height).toBeCloseToPixel(54);
expect(chart.legend.legendHitBoxes.length).toBe(5);
expect(chart.legend.legendHitBoxes.length).toBe(5);
expect(chart.legend.legendHitBoxes.length).toBe(9);

[
{h: 12, l: 56, t: 10, w: 93},
{h: 12, l: 158, t: 10, w: 93},
{h: 12, l: 261, t: 10, w: 93},
{h: 12, l: 364, t: 10, w: 93},
{h: 12, l: 210, t: 32, w: 93}
{h: 12, l: 37, t: 10, w: 46},
{h: 12, l: 93, t: 10, w: 46},
{h: 12, l: 149, t: 10, w: 46},
{h: 12, l: 205, t: 10, w: 46},
{h: 12, l: 261, t: 10, w: 46},
{h: 12, l: 317, t: 10, w: 46},
{h: 12, l: 373, t: 10, w: 46},
{h: 12, l: 429, t: 10, w: 46},
{h: 12, l: 233, t: 32, w: 46}
].forEach(function(expected, i) {
expect(chart.legend.legendHitBoxes[i].height).toBeCloseToPixel(expected.h);
expect(chart.legend.legendHitBoxes[i].left).toBeCloseToPixel(expected.l);
Expand All @@ -473,9 +476,9 @@ describe('Legend block tests', function() {
var chart = window.acquireChart({
type: 'bar',
data: {
datasets: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22].map(function(n) {
datasets: Array.apply(null, Array(22)).map(function() {
return {
label: 'dataset' + n,
label: '',
data: []
};
}),
Expand All @@ -490,33 +493,33 @@ describe('Legend block tests', function() {

expect(chart.legend.left).toBeCloseToPixel(0);
expect(chart.legend.top).toBeCloseToPixel(6);
expect(chart.legend.width).toBeCloseToPixel(228.7);
expect(chart.legend.width).toBeCloseToPixel(122);
expect(chart.legend.height).toBeCloseToPixel(478);
expect(chart.legend.legendHitBoxes.length).toBe(22);

[
{h: 12, l: 10, t: 16, w: 93},
{h: 12, l: 10, t: 38, w: 93},
{h: 12, l: 10, t: 60, w: 93},
{h: 12, l: 10, t: 82, w: 93},
{h: 12, l: 10, t: 104, w: 93},
{h: 12, l: 10, t: 126, w: 93},
{h: 12, l: 10, t: 148, w: 93},
{h: 12, l: 10, t: 170, w: 93},
{h: 12, l: 10, t: 192, w: 93},
{h: 12, l: 10, t: 214, w: 99},
{h: 12, l: 10, t: 236, w: 99},
{h: 12, l: 10, t: 258, w: 99},
{h: 12, l: 10, t: 280, w: 99},
{h: 12, l: 10, t: 302, w: 99},
{h: 12, l: 10, t: 324, w: 99},
{h: 12, l: 10, t: 346, w: 99},
{h: 12, l: 10, t: 368, w: 99},
{h: 12, l: 10, t: 390, w: 99},
{h: 12, l: 10, t: 412, w: 99},
{h: 12, l: 10, t: 434, w: 99},
{h: 12, l: 10, t: 456, w: 99},
{h: 12, l: 119, t: 16, w: 99}
{h: 12, l: 10, t: 16, w: 46},
{h: 12, l: 10, t: 38, w: 46},
{h: 12, l: 10, t: 60, w: 46},
{h: 12, l: 10, t: 82, w: 46},
{h: 12, l: 10, t: 104, w: 46},
{h: 12, l: 10, t: 126, w: 46},
{h: 12, l: 10, t: 148, w: 46},
{h: 12, l: 10, t: 170, w: 46},
{h: 12, l: 10, t: 192, w: 46},
{h: 12, l: 10, t: 214, w: 46},
{h: 12, l: 10, t: 236, w: 46},
{h: 12, l: 10, t: 258, w: 46},
{h: 12, l: 10, t: 280, w: 46},
{h: 12, l: 10, t: 302, w: 46},
{h: 12, l: 10, t: 324, w: 46},
{h: 12, l: 10, t: 346, w: 46},
{h: 12, l: 10, t: 368, w: 46},
{h: 12, l: 10, t: 390, w: 46},
{h: 12, l: 10, t: 412, w: 46},
{h: 12, l: 10, t: 434, w: 46},
{h: 12, l: 10, t: 456, w: 46},
{h: 12, l: 66, t: 16, w: 46}
].forEach(function(expected, i) {
expect(chart.legend.legendHitBoxes[i].height).toBeCloseToPixel(expected.h);
expect(chart.legend.legendHitBoxes[i].left).toBeCloseToPixel(expected.l);
Expand Down

0 comments on commit d91e821

Please sign in to comment.