]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Add test for layout service weight ordering
authoretimberg <evert.timberg@gmail.com>
Sat, 25 Feb 2017 17:05:36 +0000 (12:05 -0500)
committerEvert Timberg <evert.timberg+github@gmail.com>
Sat, 25 Feb 2017 17:10:27 +0000 (12:10 -0500)
test/core.layoutService.tests.js

index 951ea234e70e4e86eb670e04bf32b70f7563f85d..d5f5fab9125b4c40144bc38e2f780c3580728d91 100644 (file)
@@ -390,4 +390,43 @@ describe('Test the layout service', function() {
                        expect(chart.chartArea.top).toBeCloseToPixel(0);
                });
        });
+
+       describe('ordering by weight', function() {
+               it('should keep higher weights outside', function() {
+                       var chart = window.acquireChart({
+                               type: 'bar',
+                               data: {
+                                       datasets: [
+                                               {
+                                                       data: [10, 5, 0, 25, 78, -10]
+                                               }
+                                       ],
+                                       labels: ['tick1', 'tick2', 'tick3', 'tick4', 'tick5', 'tick6']
+                               },
+                               options: {
+                                       legend: {
+                                               display: true,
+                                               position: 'left',
+                                       },
+                                       title: {
+                                               display: true,
+                                               position: 'bottom',
+                                       },
+                               },
+                       }, {
+                               canvas: {
+                                       height: 150,
+                                       width: 250
+                               }
+                       });
+
+                       var xAxis = chart.scales['x-axis-0'];
+                       var yAxis = chart.scales['y-axis-0'];
+                       var legend = chart.legend;
+                       var title = chart.titleBlock;
+
+                       expect(yAxis.left).toBe(legend.right);
+                       expect(xAxis.bottom).toBe(title.top);
+               });
+       });
 });