]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Add testcases for the consistent dataset-specific option names "pointRadius" and...
authorJannis Achstetter <jannis.achstetter@schneider-electric.com>
Thu, 21 Apr 2016 13:39:19 +0000 (15:39 +0200)
committerJannis Achstetter <jannis.achstetter@schneider-electric.com>
Thu, 21 Apr 2016 13:39:19 +0000 (15:39 +0200)
test/controller.line.tests.js

index 7a4f3c9f7209cb8519ac99438c927c41426f9bfb..0d93cd2fbdf71bfc97cfd44f10a4b1a89e69588a 100644 (file)
@@ -511,6 +511,116 @@ describe('Line controller tests', function() {
       controlPointNextY: 47.22056683242656
     });
 
+    // Use the consistent name "pointRadius", setting but overwriting
+    // another value in "radius"
+    chart.data.datasets[0].pointRadius = 250;
+    chart.data.datasets[0].radius = 20;
+
+    controller.update();
+
+    expect(chart.data.datasets[0].metaDataset._model).toEqual({
+      backgroundColor: 'rgb(98, 98, 98)',
+      borderCapStyle: 'butt',
+      borderColor: 'rgb(8, 8, 8)',
+      borderDash: [2, 3],
+      borderDashOffset: 7,
+      borderJoinStyle: 'miter',
+      borderWidth: 0.55,
+      fill: false,
+      tension: 0.5,
+
+      scaleTop: 0,
+      scaleBottom: 200,
+      scaleZero: 156,
+    });
+
+    expect(chart.data.datasets[0].metaData[0]._model).toEqual({
+      x: 82,
+      y: 62,
+      radius: 250,
+      pointStyle: 'circle',
+      backgroundColor: 'rgb(128, 129, 130)',
+      borderColor: 'rgb(56, 57, 58)',
+      borderWidth: 1.123,
+      hitRadius: 3.3,
+      skip: false,
+      controlPointPreviousX: 82,
+      controlPointPreviousY: 62,
+      controlPointNextX: 107,
+      controlPointNextY: 38.5
+    });
+
+    expect(chart.data.datasets[0].metaData[1]._model).toEqual({
+      x: 132,
+      y: 15,
+      radius: 250,
+      pointStyle: 'circle',
+      backgroundColor: 'rgb(128, 129, 130)',
+      borderColor: 'rgb(56, 57, 58)',
+      borderWidth: 1.123,
+      hitRadius: 3.3,
+      skip: false,
+      controlPointPreviousX: 116.2771987579006,
+      controlPointPreviousY: 0.22056683242656483,
+      controlPointNextX: 166.2771987579006,
+      controlPointNextY: 47.22056683242656
+    });
+
+    // Use the consistent name "pointHitRadius", setting but overwriting
+    // another value in "hitRadius"
+    chart.data.datasets[0].pointHitRadius = 123;
+    chart.data.datasets[0].hitRadius = 23;
+
+    controller.update();
+
+    expect(chart.data.datasets[0].metaDataset._model).toEqual({
+      backgroundColor: 'rgb(98, 98, 98)',
+      borderCapStyle: 'butt',
+      borderColor: 'rgb(8, 8, 8)',
+      borderDash: [2, 3],
+      borderDashOffset: 7,
+      borderJoinStyle: 'miter',
+      borderWidth: 0.55,
+      fill: false,
+      tension: 0.5,
+
+      scaleTop: 0,
+      scaleBottom: 200,
+      scaleZero: 156,
+    });
+
+    expect(chart.data.datasets[0].metaData[0]._model).toEqual({
+      x: 82,
+      y: 62,
+      radius: 250,
+      pointStyle: 'circle',
+      backgroundColor: 'rgb(128, 129, 130)',
+      borderColor: 'rgb(56, 57, 58)',
+      borderWidth: 1.123,
+      hitRadius: 123,
+      skip: false,
+      controlPointPreviousX: 82,
+      controlPointPreviousY: 62,
+      controlPointNextX: 107,
+      controlPointNextY: 38.5
+    });
+
+    expect(chart.data.datasets[0].metaData[1]._model).toEqual({
+      x: 132,
+      y: 15,
+      radius: 250,
+      pointStyle: 'circle',
+      backgroundColor: 'rgb(128, 129, 130)',
+      borderColor: 'rgb(56, 57, 58)',
+      borderWidth: 1.123,
+      hitRadius: 123,
+      skip: false,
+      controlPointPreviousX: 116.2771987579006,
+      controlPointPreviousY: 0.22056683242656483,
+      controlPointNextX: 166.2771987579006,
+      controlPointNextY: 47.22056683242656
+    });
+
     // Use custom styles for lines & first point
     chart.data.datasets[0].metaDataset.custom = {
       tension: 0.15,
@@ -1326,6 +1436,17 @@ describe('Line controller tests', function() {
     expect(point._model.borderWidth).toBe(2.1);
     expect(point._model.radius).toBe(3.3);
 
+    // Use the consistent name "pointRadius", setting but overwriting
+    // another value in "radius"
+    chart.data.datasets[0].pointRadius = 250;
+    chart.data.datasets[0].radius = 20;
+
+    controller.setHoverStyle(point);
+    expect(point._model.backgroundColor).toBe('rgb(77, 79, 81)');
+    expect(point._model.borderColor).toBe('rgb(123, 125, 127)');
+    expect(point._model.borderWidth).toBe(2.1);
+    expect(point._model.radius).toBe(3.3);
+
     // Custom style
     point.custom = {
       hoverRadius: 4.4,
@@ -1468,6 +1589,17 @@ describe('Line controller tests', function() {
     expect(point._model.borderWidth).toBe(2.1);
     expect(point._model.radius).toBe(3.3);
 
+    // Use the consistent name "pointRadius", setting but overwriting
+    // another value in "radius"
+    chart.data.datasets[0].pointRadius = 250;
+    chart.data.datasets[0].radius = 20;
+
+    controller.removeHoverStyle(point);
+    expect(point._model.backgroundColor).toBe('rgb(77, 79, 81)');
+    expect(point._model.borderColor).toBe('rgb(123, 125, 127)');
+    expect(point._model.borderWidth).toBe(2.1);
+    expect(point._model.radius).toBe(250);
+
     // Custom style
     point.custom = {
       radius: 4.4,