|
1 |
| -/* global $:false, jQuery:false */ |
2 |
| - |
3 |
| -/* |
4 |
| - * Note this test requires JQuery in the global scope. |
5 |
| - * we should keep it that way to keep testing our backward |
6 |
| - * compatibility with JQuery events. |
7 |
| - */ |
8 |
| - |
9 | 1 | var Events = require('../../../src/lib/events');
|
10 | 2 |
|
11 | 3 | describe('Events', function() {
|
@@ -57,19 +49,6 @@ describe('Events', function() {
|
57 | 49 | });
|
58 | 50 | });
|
59 | 51 |
|
60 |
| - it('triggers jquery events', function(done) { |
61 |
| - Events.init(plotDiv); |
62 |
| - |
63 |
| - $(plotDiv).bind('ping', function(event, data) { |
64 |
| - expect(data).toBe('pong'); |
65 |
| - done(); |
66 |
| - }); |
67 |
| - |
68 |
| - setTimeout(function() { |
69 |
| - $(plotDiv).trigger('ping', 'pong'); |
70 |
| - }); |
71 |
| - }); |
72 |
| - |
73 | 52 | it('mirrors events on an internal handler', function(done) {
|
74 | 53 | Events.init(plotDiv);
|
75 | 54 |
|
@@ -139,86 +118,6 @@ describe('Events', function() {
|
139 | 118 | expect(result).toBe('pong');
|
140 | 119 | });
|
141 | 120 |
|
142 |
| - it('triggers jQuery handlers when no matching node events bound', function() { |
143 |
| - var eventBaton = 0; |
144 |
| - |
145 |
| - Events.init(plotDiv); |
146 |
| - |
147 |
| - $(plotDiv).bind('ping', function() { |
148 |
| - eventBaton++; |
149 |
| - return 'ping'; |
150 |
| - }); |
151 |
| - |
152 |
| - /* |
153 |
| - * This will not be called |
154 |
| - */ |
155 |
| - plotDiv.on('pong', function() { |
156 |
| - eventBaton++; |
157 |
| - return 'ping'; |
158 |
| - }); |
159 |
| - |
160 |
| - $(plotDiv).bind('ping', function() { |
161 |
| - eventBaton++; |
162 |
| - return 'pong'; |
163 |
| - }); |
164 |
| - |
165 |
| - var result = Events.triggerHandler(plotDiv, 'ping'); |
166 |
| - |
167 |
| - expect(eventBaton).toBe(2); |
168 |
| - expect(result).toBe('pong'); |
169 |
| - }); |
170 |
| - |
171 |
| - it('triggers jQuery handlers when no node events initialized', function() { |
172 |
| - var eventBaton = 0; |
173 |
| - |
174 |
| - $(plotDiv).bind('ping', function() { |
175 |
| - eventBaton++; |
176 |
| - return 'ping'; |
177 |
| - }); |
178 |
| - |
179 |
| - $(plotDiv).bind('ping', function() { |
180 |
| - eventBaton++; |
181 |
| - return 'ping'; |
182 |
| - }); |
183 |
| - |
184 |
| - $(plotDiv).bind('ping', function() { |
185 |
| - eventBaton++; |
186 |
| - return 'pong'; |
187 |
| - }); |
188 |
| - |
189 |
| - var result = Events.triggerHandler(plotDiv, 'ping'); |
190 |
| - |
191 |
| - expect(eventBaton).toBe(3); |
192 |
| - expect(result).toBe('pong'); |
193 |
| - }); |
194 |
| - |
195 |
| - |
196 |
| - it('triggers jQuery + nodejs handlers and returns last jQuery value', function() { |
197 |
| - var eventBaton = 0; |
198 |
| - |
199 |
| - Events.init(plotDiv); |
200 |
| - |
201 |
| - $(plotDiv).bind('ping', function() { |
202 |
| - eventBaton++; |
203 |
| - return 'ping'; |
204 |
| - }); |
205 |
| - |
206 |
| - plotDiv.on('ping', function() { |
207 |
| - eventBaton++; |
208 |
| - return 'ping'; |
209 |
| - }); |
210 |
| - |
211 |
| - $(plotDiv).bind('ping', function() { |
212 |
| - eventBaton++; |
213 |
| - return 'pong'; |
214 |
| - }); |
215 |
| - |
216 |
| - var result = Events.triggerHandler(plotDiv, 'ping'); |
217 |
| - |
218 |
| - expect(eventBaton).toBe(3); |
219 |
| - expect(result).toBe('pong'); |
220 |
| - }); |
221 |
| - |
222 | 121 | it('works with *once* event handlers', function() {
|
223 | 122 | var eventBaton = 0;
|
224 | 123 |
|
@@ -247,106 +146,4 @@ describe('Events', function() {
|
247 | 146 | expect(plotObj).toEqual({});
|
248 | 147 | });
|
249 | 148 | });
|
250 |
| - |
251 |
| - describe('when jQuery.noConflict is set, ', function() { |
252 |
| - beforeEach(function() { |
253 |
| - $.noConflict(); |
254 |
| - }); |
255 |
| - |
256 |
| - afterEach(function() { |
257 |
| - window.$ = jQuery; |
258 |
| - }); |
259 |
| - |
260 |
| - it('triggers jquery events', function(done) { |
261 |
| - Events.init(plotDiv); |
262 |
| - |
263 |
| - jQuery(plotDiv).bind('ping', function(event, data) { |
264 |
| - expect(data).toBe('pong'); |
265 |
| - done(); |
266 |
| - }); |
267 |
| - |
268 |
| - setTimeout(function() { |
269 |
| - jQuery(plotDiv).trigger('ping', 'pong'); |
270 |
| - }); |
271 |
| - }); |
272 |
| - |
273 |
| - it('triggers jQuery handlers when no matching node events bound', function() { |
274 |
| - var eventBaton = 0; |
275 |
| - |
276 |
| - Events.init(plotDiv); |
277 |
| - |
278 |
| - jQuery(plotDiv).bind('ping', function() { |
279 |
| - eventBaton++; |
280 |
| - return 'ping'; |
281 |
| - }); |
282 |
| - |
283 |
| - /* |
284 |
| - * This will not be called |
285 |
| - */ |
286 |
| - plotDiv.on('pong', function() { |
287 |
| - eventBaton++; |
288 |
| - return 'ping'; |
289 |
| - }); |
290 |
| - |
291 |
| - jQuery(plotDiv).bind('ping', function() { |
292 |
| - eventBaton++; |
293 |
| - return 'pong'; |
294 |
| - }); |
295 |
| - |
296 |
| - var result = Events.triggerHandler(plotDiv, 'ping'); |
297 |
| - |
298 |
| - expect(eventBaton).toBe(2); |
299 |
| - expect(result).toBe('pong'); |
300 |
| - }); |
301 |
| - |
302 |
| - it('triggers jQuery handlers when no node events initialized', function() { |
303 |
| - var eventBaton = 0; |
304 |
| - |
305 |
| - jQuery(plotDiv).bind('ping', function() { |
306 |
| - eventBaton++; |
307 |
| - return 'ping'; |
308 |
| - }); |
309 |
| - |
310 |
| - jQuery(plotDiv).bind('ping', function() { |
311 |
| - eventBaton++; |
312 |
| - return 'ping'; |
313 |
| - }); |
314 |
| - |
315 |
| - jQuery(plotDiv).bind('ping', function() { |
316 |
| - eventBaton++; |
317 |
| - return 'pong'; |
318 |
| - }); |
319 |
| - |
320 |
| - var result = Events.triggerHandler(plotDiv, 'ping'); |
321 |
| - |
322 |
| - expect(eventBaton).toBe(3); |
323 |
| - expect(result).toBe('pong'); |
324 |
| - }); |
325 |
| - |
326 |
| - it('triggers jQuery + nodejs handlers and returns last jQuery value', function() { |
327 |
| - var eventBaton = 0; |
328 |
| - |
329 |
| - Events.init(plotDiv); |
330 |
| - |
331 |
| - jQuery(plotDiv).bind('ping', function() { |
332 |
| - eventBaton++; |
333 |
| - return 'ping'; |
334 |
| - }); |
335 |
| - |
336 |
| - plotDiv.on('ping', function() { |
337 |
| - eventBaton++; |
338 |
| - return 'ping'; |
339 |
| - }); |
340 |
| - |
341 |
| - jQuery(plotDiv).bind('ping', function() { |
342 |
| - eventBaton++; |
343 |
| - return 'pong'; |
344 |
| - }); |
345 |
| - |
346 |
| - var result = Events.triggerHandler(plotDiv, 'ping'); |
347 |
| - |
348 |
| - expect(eventBaton).toBe(3); |
349 |
| - expect(result).toBe('pong'); |
350 |
| - }); |
351 |
| - }); |
352 | 149 | });
|
0 commit comments