|
1 | 1 | var Plotly = require('@lib/index');
|
2 | 2 | var Lib = require('@src/lib');
|
3 | 3 | var constants = require('@src/components/legend/constants');
|
| 4 | +var DBLCLICKDELAY = require('@src/constants/interactions').DBLCLICKDELAY; |
4 | 5 |
|
5 | 6 | var d3 = require('d3');
|
6 | 7 | var createGraph = require('../assets/create_graph_div');
|
7 | 8 | var destroyGraph = require('../assets/destroy_graph_div');
|
8 | 9 | var getBBox = require('../assets/get_bbox');
|
9 | 10 | var mock = require('../../image/mocks/legend_scroll.json');
|
10 | 11 |
|
11 |
| - |
12 | 12 | describe('The legend', function() {
|
13 | 13 | 'use strict';
|
14 | 14 |
|
@@ -105,11 +105,15 @@ describe('The legend', function() {
|
105 | 105 | legend.dispatchEvent(scrollTo(wheelDeltaY));
|
106 | 106 |
|
107 | 107 | var dataScroll = scrollBox.getAttribute('data-scroll');
|
108 |
| - toggle.dispatchEvent(new MouseEvent('click')); |
109 |
| - expect(+toggle.parentNode.style.opacity).toBeLessThan(1); |
110 |
| - expect(scrollBox.getAttribute('data-scroll')).toBe(dataScroll); |
111 |
| - expect(scrollBox.getAttribute('transform')).toBe( |
112 |
| - 'translate(0, ' + dataScroll + ')'); |
| 108 | + toggle.dispatchEvent(new MouseEvent('mousedown')); |
| 109 | + toggle.dispatchEvent(new MouseEvent('mouseup')); |
| 110 | + setTimeout(function() { |
| 111 | + expect(+toggle.parentNode.style.opacity).toBeLessThan(1); |
| 112 | + expect(scrollBox.getAttribute('data-scroll')).toBe(dataScroll); |
| 113 | + expect(scrollBox.getAttribute('transform')).toBe( |
| 114 | + 'translate(0, ' + dataScroll + ')'); |
| 115 | + done(); |
| 116 | + }, DBLCLICKDELAY * 2); |
113 | 117 | });
|
114 | 118 |
|
115 | 119 | it('should be restored and functional after relayout', function() {
|
@@ -139,13 +143,16 @@ describe('The legend', function() {
|
139 | 143 | expect(scrollBar.getAttribute('y')).toBe(scrollBarY);
|
140 | 144 |
|
141 | 145 | var dataScroll = scrollBox.getAttribute('data-scroll');
|
142 |
| - toggle.dispatchEvent(new MouseEvent('click')); |
143 |
| - expect(+toggle.parentNode.style.opacity).toBeLessThan(1); |
144 |
| - expect(scrollBox.getAttribute('data-scroll')).toBe(dataScroll); |
145 |
| - expect(scrollBox.getAttribute('transform')).toBe( |
146 |
| - 'translate(0, ' + dataScroll + ')'); |
147 |
| - expect(scrollBar.getAttribute('width')).toBeGreaterThan(0); |
148 |
| - expect(scrollBar.getAttribute('height')).toBeGreaterThan(0); |
| 146 | + toggle.dispatchEvent(new MouseEvent('mousedown')); |
| 147 | + toggle.dispatchEvent(new MouseEvent('mouseup')); |
| 148 | + setTimeout(function() { |
| 149 | + expect(+toggle.parentNode.style.opacity).toBeLessThan(1); |
| 150 | + expect(scrollBox.getAttribute('data-scroll')).toBe(dataScroll); |
| 151 | + expect(scrollBox.getAttribute('transform')).toBe( |
| 152 | + 'translate(0, ' + dataScroll + ')'); |
| 153 | + expect(scrollBar.getAttribute('width')).toBeGreaterThan(0); |
| 154 | + expect(scrollBar.getAttribute('height')).toBeGreaterThan(0); |
| 155 | + }, DBLCLICKDELAY * 2); |
149 | 156 | });
|
150 | 157 |
|
151 | 158 | it('should constrain scrolling to the contents', function() {
|
|
0 commit comments