Skip to content

Commit 1021272

Browse files
committed
test: hiding and showing back a legend
* Tested that event listeners in a legend work after hiding and showing back the legend.
1 parent 9b6baa8 commit 1021272

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/jasmine/tests/legend_scroll_test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,27 @@ describe('The legend', function() {
8585
wheelDeltaY = 100;
8686

8787
legend.dispatchEvent(scrollTo(wheelDeltaY));
88+
8889
var dataScroll = scrollBox.getAttribute('data-scroll');
90+
toggle.dispatchEvent(new MouseEvent('click'));
91+
expect(+toggle.parentNode.style.opacity).toBeLessThan(1);
92+
expect(scrollBox.getAttribute('data-scroll')).toBe(dataScroll);
93+
expect(scrollBox.getAttribute('transform')).toBe(
94+
'translate(0, ' + dataScroll + ')');
95+
});
8996

97+
it('should keep toggle listeners after relayout', function() {
98+
Plotly.relayout(gd, 'showlegend', false);
99+
Plotly.relayout(gd, 'showlegend', true);
100+
101+
var legend = document.getElementsByClassName('legend')[0],
102+
scrollBox = legend.getElementsByClassName('scrollbox')[0],
103+
toggle = legend.getElementsByClassName('legendtoggle')[0],
104+
wheelDeltaY = 100;
105+
106+
legend.dispatchEvent(scrollTo(wheelDeltaY));
107+
108+
var dataScroll = scrollBox.getAttribute('data-scroll');
90109
toggle.dispatchEvent(new MouseEvent('click'));
91110
expect(+toggle.parentNode.style.opacity).toBeLessThan(1);
92111
expect(scrollBox.getAttribute('data-scroll')).toBe(dataScroll);

0 commit comments

Comments
 (0)