(gd)
| 77 | var selectedPromise, deselectPromise, clickedPromise, relayoutPromise; |
| 78 | |
| 79 | function resetEvents(gd) { |
| 80 | selectingCnt = 0; |
| 81 | selectedCnt = 0; |
| 82 | deselectCnt = 0; |
| 83 | doubleClickData = null; |
| 84 | |
| 85 | gd.removeAllListeners(); |
| 86 | |
| 87 | selectedPromise = new Promise(function(resolve) { |
| 88 | gd.on('plotly_selecting', function(data) { |
| 89 | // note that since all of these events test node counts, |
| 90 | // and all of the other tests at some point check that each of |
| 91 | // these event handlers was called (via assertEventCounts), |
| 92 | // we no longer need separate tests that these nodes are created |
| 93 | // and this way *all* subplot variants get the test. |
| 94 | assertSelectionNodes(1, 1); |
| 95 | selectingCnt++; |
| 96 | selectingData = data; |
| 97 | }); |
| 98 | |
| 99 | gd.on('plotly_selected', function(data) { |
| 100 | // With click-to-select supported, selection nodes are only |
| 101 | // in the DOM in certain circumstances. |
| 102 | if(data && |
| 103 | gd._fullLayout.dragmode.indexOf('select') > -1 && |
| 104 | gd._fullLayout.dragmode.indexOf('lasso') > -1) { |
| 105 | assertSelectionNodes(0, 1); |
| 106 | } |
| 107 | selectedCnt++; |
| 108 | selectedData = data; |
| 109 | resolve(); |
| 110 | }); |
| 111 | }); |
| 112 | |
| 113 | deselectPromise = new Promise(function(resolve) { |
| 114 | gd.on('plotly_deselect', function(data) { |
| 115 | assertSelectionNodes(0, 0); |
| 116 | deselectCnt++; |
| 117 | doubleClickData = data; |
| 118 | resolve(); |
| 119 | }); |
| 120 | }); |
| 121 | |
| 122 | clickedPromise = new Promise(function(resolve) { |
| 123 | gd.on('plotly_click', function() { |
| 124 | resolve(); |
| 125 | }); |
| 126 | }); |
| 127 | |
| 128 | relayoutPromise = new Promise(function(resolve) { |
| 129 | gd.on('plotly_relayout', function() { |
| 130 | resolve(); |
| 131 | }); |
| 132 | }); |
| 133 | } |
| 134 | |
| 135 | function assertEventCounts(selecting, selected, deselect, msg) { |
| 136 | expect(selectingCnt).toBe(selecting, 'plotly_selecting call count: ' + msg); |
no test coverage detected
searching dependent graphs…