Skip to content

Commit 7a10774

Browse files
committed
Use empty labels for tests so as not to be affected by the font width
1 parent f6d9a39 commit 7a10774

File tree

1 file changed

+39
-36
lines changed

1 file changed

+39
-36
lines changed

test/specs/plugin.legend.tests.js

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ describe('Legend block tests', function() {
205205
expect(chart.legend.legendHitBoxes.length).toBe(3);
206206

207207
[
208-
{h: 12, l: 107, t: 10, w: 93},
209-
{h: 12, l: 210, t: 10, w: 93},
208+
{h: 12, l: 106, t: 10, w: 93},
209+
{h: 12, l: 209, t: 10, w: 93},
210210
{h: 12, l: 312, t: 10, w: 93}
211211
].forEach(function(expected, i) {
212212
expect(chart.legend.legendHitBoxes[i].height).toBeCloseToPixel(expected.h);
@@ -438,9 +438,9 @@ describe('Legend block tests', function() {
438438
var chart = window.acquireChart({
439439
type: 'bar',
440440
data: {
441-
datasets: [1, 2, 3, 4, 5].map(function(n) {
441+
datasets: Array.apply(null, Array(9)).map(function() {
442442
return {
443-
label: 'dataset' + n,
443+
label: ' ',
444444
data: []
445445
};
446446
}),
@@ -452,15 +452,18 @@ describe('Legend block tests', function() {
452452
expect(chart.legend.top).toBeCloseToPixel(0);
453453
expect(chart.legend.width).toBeCloseToPixel(512);
454454
expect(chart.legend.height).toBeCloseToPixel(54);
455-
expect(chart.legend.legendHitBoxes.length).toBe(5);
456-
expect(chart.legend.legendHitBoxes.length).toBe(5);
455+
expect(chart.legend.legendHitBoxes.length).toBe(9);
457456

458457
[
459-
{h: 12, l: 56, t: 10, w: 93},
460-
{h: 12, l: 158, t: 10, w: 93},
461-
{h: 12, l: 261, t: 10, w: 93},
462-
{h: 12, l: 364, t: 10, w: 93},
463-
{h: 12, l: 210, t: 32, w: 93}
458+
{h: 12, l: 24, t: 10, w: 49},
459+
{h: 12, l: 83, t: 10, w: 49},
460+
{h: 12, l: 142, t: 10, w: 49},
461+
{h: 12, l: 202, t: 10, w: 49},
462+
{h: 12, l: 261, t: 10, w: 49},
463+
{h: 12, l: 320, t: 10, w: 49},
464+
{h: 12, l: 380, t: 10, w: 49},
465+
{h: 12, l: 439, t: 10, w: 49},
466+
{h: 12, l: 231, t: 32, w: 49}
464467
].forEach(function(expected, i) {
465468
expect(chart.legend.legendHitBoxes[i].height).toBeCloseToPixel(expected.h);
466469
expect(chart.legend.legendHitBoxes[i].left).toBeCloseToPixel(expected.l);
@@ -473,9 +476,9 @@ describe('Legend block tests', function() {
473476
var chart = window.acquireChart({
474477
type: 'bar',
475478
data: {
476-
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) {
479+
datasets: Array.apply(null, Array(22)).map(function() {
477480
return {
478-
label: 'dataset' + n,
481+
label: ' ',
479482
data: []
480483
};
481484
}),
@@ -490,33 +493,33 @@ describe('Legend block tests', function() {
490493

491494
expect(chart.legend.left).toBeCloseToPixel(0);
492495
expect(chart.legend.top).toBeCloseToPixel(6);
493-
expect(chart.legend.width).toBeCloseToPixel(228.7);
496+
expect(chart.legend.width).toBeCloseToPixel(128);
494497
expect(chart.legend.height).toBeCloseToPixel(478);
495498
expect(chart.legend.legendHitBoxes.length).toBe(22);
496499

497500
[
498-
{h: 12, l: 10, t: 16, w: 93},
499-
{h: 12, l: 10, t: 38, w: 93},
500-
{h: 12, l: 10, t: 60, w: 93},
501-
{h: 12, l: 10, t: 82, w: 93},
502-
{h: 12, l: 10, t: 104, w: 93},
503-
{h: 12, l: 10, t: 126, w: 93},
504-
{h: 12, l: 10, t: 148, w: 93},
505-
{h: 12, l: 10, t: 170, w: 93},
506-
{h: 12, l: 10, t: 192, w: 93},
507-
{h: 12, l: 10, t: 214, w: 99},
508-
{h: 12, l: 10, t: 236, w: 99},
509-
{h: 12, l: 10, t: 258, w: 99},
510-
{h: 12, l: 10, t: 280, w: 99},
511-
{h: 12, l: 10, t: 302, w: 99},
512-
{h: 12, l: 10, t: 324, w: 99},
513-
{h: 12, l: 10, t: 346, w: 99},
514-
{h: 12, l: 10, t: 368, w: 99},
515-
{h: 12, l: 10, t: 390, w: 99},
516-
{h: 12, l: 10, t: 412, w: 99},
517-
{h: 12, l: 10, t: 434, w: 99},
518-
{h: 12, l: 10, t: 456, w: 99},
519-
{h: 12, l: 119, t: 16, w: 99}
501+
{h: 12, l: 10, t: 16, w: 49},
502+
{h: 12, l: 10, t: 38, w: 49},
503+
{h: 12, l: 10, t: 60, w: 49},
504+
{h: 12, l: 10, t: 82, w: 49},
505+
{h: 12, l: 10, t: 104, w: 49},
506+
{h: 12, l: 10, t: 126, w: 49},
507+
{h: 12, l: 10, t: 148, w: 49},
508+
{h: 12, l: 10, t: 170, w: 49},
509+
{h: 12, l: 10, t: 192, w: 49},
510+
{h: 12, l: 10, t: 214, w: 49},
511+
{h: 12, l: 10, t: 236, w: 49},
512+
{h: 12, l: 10, t: 258, w: 49},
513+
{h: 12, l: 10, t: 280, w: 49},
514+
{h: 12, l: 10, t: 302, w: 49},
515+
{h: 12, l: 10, t: 324, w: 49},
516+
{h: 12, l: 10, t: 346, w: 49},
517+
{h: 12, l: 10, t: 368, w: 49},
518+
{h: 12, l: 10, t: 390, w: 49},
519+
{h: 12, l: 10, t: 412, w: 49},
520+
{h: 12, l: 10, t: 434, w: 49},
521+
{h: 12, l: 10, t: 456, w: 49},
522+
{h: 12, l: 69, t: 16, w: 49}
520523
].forEach(function(expected, i) {
521524
expect(chart.legend.legendHitBoxes[i].height).toBeCloseToPixel(expected.h);
522525
expect(chart.legend.legendHitBoxes[i].left).toBeCloseToPixel(expected.l);

0 commit comments

Comments
 (0)