From: Evert Timberg Date: Sun, 29 May 2016 00:55:20 +0000 (-0400) Subject: Improve testing on the CI X-Git-Tag: v2.1.5~28^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6bc917c8e3168aee488f1b716bc1dbd174c52b95;p=thirdparty%2FChart.js.git Improve testing on the CI --- diff --git a/src/core/core.tooltip.js b/src/core/core.tooltip.js index e56ff0ec3..e7abf7229 100644 --- a/src/core/core.tooltip.js +++ b/src/core/core.tooltip.js @@ -282,10 +282,10 @@ module.exports = function(Chart) { model.opacity = 1; var labelColors = [], - tooltipPosition = tooltipPosition = getAveragePosition(active); + tooltipPosition = getAveragePosition(active); var tooltipItems = []; - for (var i = 0, len = active.length; i < len; ++i) { + for (i = 0, len = active.length; i < len; ++i) { tooltipItems.push(createTooltipItem(active[i])); } @@ -601,7 +601,7 @@ module.exports = function(Chart) { var bodyColor = helpers.color(vm.bodyColor); var textColor = bodyColor.alpha(opacity * bodyColor.alpha()).rgbString(); - ctx.fillStyle = textColor + ctx.fillStyle = textColor; ctx.font = helpers.fontString(bodyFontSize, vm._bodyFontStyle, vm._bodyFontFamily); // Before Body @@ -615,7 +615,7 @@ module.exports = function(Chart) { helpers.each(vm.beforeBody, fillLineOfText); var drawColorBoxes = body.length > 1; - xLinePadding = drawColorBoxes ? (bodyFontSize + 2) : 0 + xLinePadding = drawColorBoxes ? (bodyFontSize + 2) : 0; // Draw body lines now helpers.each(body, function(bodyItem, i) { diff --git a/test/core.tooltip.tests.js b/test/core.tooltip.tests.js index 334fdf653..bf48b6f48 100644 --- a/test/core.tooltip.tests.js +++ b/test/core.tooltip.tests.js @@ -109,8 +109,6 @@ describe('tooltip tests', function() { }], afterBody: [], footer: [], - x: 269, - y: 155, caretPadding: 2, labelColors: [{ borderColor: 'rgb(255, 0, 0)', @@ -120,6 +118,9 @@ describe('tooltip tests', function() { backgroundColor: 'rgb(0, 255, 255)' }] })); + + expect(tooltip._view.x).toBeCloseToPixel(269); + expect(tooltip._view.y).toBeCloseToPixel(155); }); it('Should display in single mode', function() { @@ -218,11 +219,12 @@ describe('tooltip tests', function() { }], afterBody: [], footer: [], - x: 269, - y: 312, caretPadding: 2, labelColors: [] })); + + expect(tooltip._view.x).toBeCloseToPixel(269); + expect(tooltip._view.y).toBeCloseToPixel(312); }); it('Should display information from user callbacks', function() { @@ -360,8 +362,6 @@ describe('tooltip tests', function() { }], afterBody: ['afterBody'], footer: ['beforeFooter', 'footer', 'afterFooter'], - x: 216, - y: 190, caretPadding: 2, labelColors: [{ borderColor: 'rgb(255, 0, 0)', @@ -371,6 +371,9 @@ describe('tooltip tests', function() { backgroundColor: 'rgb(0, 255, 255)' }] })); + + expect(tooltip._view.x).toBeCloseToPixel(216); + expect(tooltip._view.y).toBeCloseToPixel(190); }); it('Should display information from user callbacks', function() { @@ -443,8 +446,6 @@ describe('tooltip tests', function() { }], afterBody: [], footer: [], - x: 269, - y: 155, labelColors: [{ borderColor: 'rgb(0, 0, 255)', backgroundColor: 'rgb(0, 255, 255)' @@ -453,5 +454,8 @@ describe('tooltip tests', function() { backgroundColor: 'rgb(0, 255, 0)' }] })); + + expect(tooltip._view.x).toBeCloseToPixel(269); + expect(tooltip._view.y).toBeCloseToPixel(155); }); });