MCPcopy Index your code
hub / github.com/plotly/plotly.js / resetEvents

Function resetEvents

test/jasmine/tests/select_test.js:79–133  ·  view source on GitHub ↗
(gd)

Source from the content-addressed store, hash-verified

77var selectedPromise, deselectPromise, clickedPromise, relayoutPromise;
78
79function 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
135function assertEventCounts(selecting, selected, deselect, msg) {
136 expect(selectingCnt).toBe(selecting, 'plotly_selecting call count: ' + msg);

Callers 7

_clickFunction · 0.85
select_test.jsFile · 0.85
resetAndSelectFunction · 0.85
resetAndLassoFunction · 0.85
_dragFunction · 0.85
selectDragFunction · 0.85
_runFunction · 0.85

Calls 1

assertSelectionNodesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…