]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Improve testing on the CI
authorEvert Timberg <evert.timberg+github@gmail.com>
Sun, 29 May 2016 00:55:20 +0000 (20:55 -0400)
committerEvert Timberg <evert.timberg+github@gmail.com>
Sun, 29 May 2016 01:08:20 +0000 (21:08 -0400)
src/core/core.tooltip.js
test/core.tooltip.tests.js

index e56ff0ec3f24a53bc1db49a2bcbb02ef3b96e06b..e7abf722940c6c176f3fdc7280c1ad76767929bf 100644 (file)
@@ -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) {
index 334fdf653e50400bed211f7becc80d0ed47d9bf3..bf48b6f489f832d34cfcf6a1f4b55510f0ff3681 100644 (file)
@@ -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);
        });
 });