]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Test default tooltip callbacks for scatter charts (#5967)
authorNodar Nutsubidze <3382617+MadRussian@users.noreply.github.com>
Wed, 9 Jan 2019 13:37:25 +0000 (07:37 -0600)
committerSimon Brunel <simonbrunel@users.noreply.github.com>
Wed, 9 Jan 2019 13:37:25 +0000 (14:37 +0100)
This moves the mouse over the drawn point and verifies that there is no title in the tooltip and that the body contains expected content.

test/specs/controller.scatter.test.js

index 6063caed7661ff3d634c5cb6ffc641dc7af016c0..bc1ff18bf49969f5be654bf64c63f48a6e861a52 100644 (file)
@@ -3,6 +3,28 @@ describe('Chart.controllers.scatter', function() {
                expect(typeof Chart.controllers.scatter).toBe('function');
        });
 
+       it('should test default tooltip callbacks', function() {
+               var chart = window.acquireChart({
+                       type: 'scatter',
+                       data: {
+                               datasets: [{
+                                       data: [{
+                                               x: 10,
+                                               y: 15
+                                       }],
+                                       label: 'dataset1'
+                               }],
+                       },
+                       options: {}
+               });
+               var point = chart.getDatasetMeta(0).data[0];
+               jasmine.triggerMouseEvent(chart, 'mousemove', point);
+
+               // Title should be empty
+               expect(chart.tooltip._view.title.length).toBe(0);
+               expect(chart.tooltip._view.body[0].lines).toEqual(['(10, 15)']);
+       });
+
        describe('showLines option', function() {
                it('should not draw a line if undefined', function() {
                        var chart = window.acquireChart({