|
1 | 1 | var Plots = require('@src/plots/plots');
|
| 2 | +var Lib = require('@src/lib'); |
2 | 3 |
|
3 | 4 | var Legend = require('@src/components/legend');
|
4 | 5 | var getLegendData = require('@src/components/legend/get_legend_data');
|
@@ -65,6 +66,46 @@ describe('Test legend:', function() {
|
65 | 66 | expect(layoutOut.legend.traceorder).toEqual('grouped+reversed');
|
66 | 67 | });
|
67 | 68 |
|
| 69 | + it('should default orientation to vertical', function() { |
| 70 | + supplyLayoutDefaults(layoutIn, layoutOut, []); |
| 71 | + expect(layoutOut.legend.orientation).toEqual('v'); |
| 72 | + }); |
| 73 | + |
| 74 | + describe('for horizontal legends', function() { |
| 75 | + var layoutInForHorizontalLegends; |
| 76 | + |
| 77 | + beforeEach(function() { |
| 78 | + layoutInForHorizontalLegends = Lib.extendDeep({ |
| 79 | + legend: { |
| 80 | + orientation: 'h' |
| 81 | + }, |
| 82 | + xaxis: { |
| 83 | + rangeslider: { |
| 84 | + visible: false |
| 85 | + } |
| 86 | + } |
| 87 | + }, layoutIn); |
| 88 | + }); |
| 89 | + |
| 90 | + it('should default position to bottom left', function() { |
| 91 | + supplyLayoutDefaults(layoutInForHorizontalLegends, layoutOut, []); |
| 92 | + expect(layoutOut.legend.x).toEqual(0); |
| 93 | + expect(layoutOut.legend.xanchor).toEqual('left'); |
| 94 | + expect(layoutOut.legend.y).toEqual(-0.1); |
| 95 | + expect(layoutOut.legend.yanchor).toEqual('top'); |
| 96 | + }); |
| 97 | + |
| 98 | + it('should default position to top left if a range slider present', function() { |
| 99 | + var mockLayoutIn = Lib.extendDeep({}, layoutInForHorizontalLegends); |
| 100 | + mockLayoutIn.xaxis.rangeslider.visible = true; |
| 101 | + |
| 102 | + supplyLayoutDefaults(mockLayoutIn, layoutOut, []); |
| 103 | + expect(layoutOut.legend.x).toEqual(0); |
| 104 | + expect(layoutOut.legend.xanchor).toEqual('left'); |
| 105 | + expect(layoutOut.legend.y).toEqual(1.1); |
| 106 | + expect(layoutOut.legend.yanchor).toEqual('bottom'); |
| 107 | + }); |
| 108 | + }); |
68 | 109 | });
|
69 | 110 |
|
70 | 111 | describe('getLegendData', function() {
|
|
0 commit comments