Skip to content

Commit 12c7604

Browse files
committed
test: legend scrollbar is restored after relayout
1 parent 17d07c0 commit 12c7604

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

test/jasmine/tests/legend_scroll_test.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,22 @@ describe('The legend', function() {
9494
'translate(0, ' + dataScroll + ')');
9595
});
9696

97-
it('should keep toggle listeners after relayout', function() {
97+
it('should be restored and functional after relayout', function() {
98+
var wheelDeltaY = 100,
99+
legend = document.getElementsByClassName('legend')[0],
100+
scrollBox,
101+
scrollBar,
102+
toggle;
103+
104+
legend.dispatchEvent(scrollTo(wheelDeltaY));
105+
98106
Plotly.relayout(gd, 'showlegend', false);
99107
Plotly.relayout(gd, 'showlegend', true);
100108

101-
var legend = document.getElementsByClassName('legend')[0],
102-
scrollBox = legend.getElementsByClassName('scrollbox')[0],
103-
toggle = legend.getElementsByClassName('legendtoggle')[0],
104-
wheelDeltaY = 100;
109+
legend = document.getElementsByClassName('legend')[0];
110+
scrollBox = legend.getElementsByClassName('scrollbox')[0];
111+
scrollBar = legend.getElementsByClassName('scrollbar')[0];
112+
toggle = legend.getElementsByClassName('legendtoggle')[0];
105113

106114
legend.dispatchEvent(scrollTo(wheelDeltaY));
107115

@@ -111,6 +119,8 @@ describe('The legend', function() {
111119
expect(scrollBox.getAttribute('data-scroll')).toBe(dataScroll);
112120
expect(scrollBox.getAttribute('transform')).toBe(
113121
'translate(0, ' + dataScroll + ')');
122+
expect(scrollBar.getAttribute('width')).toBeGreaterThan(0);
123+
expect(scrollBar.getAttribute('height')).toBeGreaterThan(0);
114124
});
115125

116126
it('should constrain scrolling to the contents', function() {

0 commit comments

Comments
 (0)