@samitouri / QOS-React-2 / commits / b9310a8fa5

Consistently use `calls.length` instead of `callCount` for Jasmine spies

Matias Singers committed Feb 10, 2015 at 09:46 UTC b9310a8fa5861211871d7cd14e87198872c16fc3
7 files changed +26 -26
src/browser/__tests__/ReactBrowserEventEmitter-test.js
+1 -1
@@ -377,7 +377,7 @@ describe('ReactBrowserEventEmitter', function() {
377 spyOn(EventListener, 'listen');
378 ReactBrowserEventEmitter.listenTo(ON_CLICK_KEY, document);
379 ReactBrowserEventEmitter.listenTo(ON_CLICK_KEY, document);
380 - expect(EventListener.listen.callCount).toBe(1);
380 + expect(EventListener.listen.calls.length).toBe(1);
381 });
382
383 it('should work with event plugins without dependencies', function() {
src/browser/eventPlugins/__tests__/ResponderEventPlugin-test.js
+19 -19
@@ -268,7 +268,7 @@ describe('ResponderEventPlugin', function() {
268 extracted = extractForMouseMove(CHILD_ID);
269 assertNothingExtracted(extracted);
270 // Not going to call `onMoveShould`* if not touching.
271 - expect(spies.onMoveShouldSetResponderParent.callCount).toBe(0);
271 + expect(spies.onMoveShouldSetResponderParent.calls.length).toBe(0);
272 expect(ResponderEventPlugin.getResponderID()).toBe(null);
273
274 // Now try the move extraction again, this time while holding down, and not
@@ -280,7 +280,7 @@ describe('ResponderEventPlugin', function() {
280 // Now moving can set the responder, if pressing down, even if there is no
281 // current responder.
282 extracted = extractForMouseMove(CHILD_ID);
283 - expect(spies.onMoveShouldSetResponderParent.callCount).toBe(1);
283 + expect(spies.onMoveShouldSetResponderParent.calls.length).toBe(1);
284 expect(ResponderEventPlugin.getResponderID()).toBe(PARENT_ID);
285 assertGrantEvent(PARENT_ID, extracted);
286
@@ -297,7 +297,7 @@ describe('ResponderEventPlugin', function() {
297
298 extracted = extractForTouchStart(CHILD_ID);
299 assertGrantEvent(CHILD_ID, extracted);
300 - expect(spies.onStartShouldSetResponderChild.callCount).toBe(1);
300 + expect(spies.onStartShouldSetResponderChild.calls.length).toBe(1);
301
302 // Now we do *not* clear out the touch via a simulated touch end. This mocks
303 // out an environment that likely will never happen, but could in some odd
@@ -305,7 +305,7 @@ describe('ResponderEventPlugin', function() {
305 // extractForTouchEnd(CHILD_ID); // Clear the responder
306 extracted = extractForTouchStart(CHILD_ID);
307 assertNothingExtracted();
308 - expect(spies.onStartShouldSetResponderChild.callCount).toBe(2);
308 + expect(spies.onStartShouldSetResponderChild.calls.length).toBe(2);
309 });
310
311 it('should bubble/capture responder on start', function() {
@@ -324,8 +324,8 @@ describe('ResponderEventPlugin', function() {
324
325 extracted = extractForTouchStart(CHILD_ID);
326 assertGrantEvent(CHILD_ID, extracted);
327 - expect(spies.onStartShouldSetResponderChild.callCount).toBe(1);
328 - expect(spies.onStartShouldSetResponderParent.callCount).toBe(0);
327 + expect(spies.onStartShouldSetResponderChild.calls.length).toBe(1);
328 + expect(spies.onStartShouldSetResponderParent.calls.length).toBe(0);
329
330 // Even if moving on the grandparent, the child will receive responder moves
331 // (This is even true for mouse interactions - which we should absolutely
@@ -372,7 +372,7 @@ describe('ResponderEventPlugin', function() {
372
373 var extracted = extractForTouchStart(CHILD_ID);
374 assertNothingExtracted(extracted);
375 - expect(spies.onStartShouldSetResponderChild.callCount).toBe(1);
375 + expect(spies.onStartShouldSetResponderChild.calls.length).toBe(1);
376 expect(ResponderEventPlugin.getResponderID()).toBe(CHILD_ID);
377 extractForTouchEnd(CHILD_ID); // Clear the responder
378
@@ -381,7 +381,7 @@ describe('ResponderEventPlugin', function() {
381 onStartShouldSetResponder(CHILD_ID, spies.onStartShouldSetResponderChild);
382 extracted = extractForTouchStart(CHILD_ID);
383 assertNothingExtracted(extracted);
384 - expect(spies.onStartShouldSetResponderChild.callCount).toBe(2);
384 + expect(spies.onStartShouldSetResponderChild.calls.length).toBe(2);
385 expect(ResponderEventPlugin.getResponderID()).toBe(null);
386 extractForTouchEnd(CHILD_ID);
387 expect(ResponderEventPlugin.getResponderID()).toBe(null); // Still null
@@ -391,7 +391,7 @@ describe('ResponderEventPlugin', function() {
391 onStartShouldSetResponder(CHILD_ID, spies.onStartShouldSetResponderChild);
392 onResponderGrant(CHILD_ID, onGrantChild);
393 extracted = extractForTouchStart(CHILD_ID);
394 - expect(spies.onStartShouldSetResponderChild.callCount).toBe(3);
394 + expect(spies.onStartShouldSetResponderChild.calls.length).toBe(3);
395 assertGrantEvent(CHILD_ID, extracted);
396 extracted = extractForTouchEnd(CHILD_ID); // Clear the responder
397 assertRelease(CHILD_ID, extracted);
@@ -410,12 +410,12 @@ describe('ResponderEventPlugin', function() {
410 spies.onStartShouldSetResponderChild.andReturn(true);
411 onStartShouldSetResponder(CHILD_ID, spies.onStartShouldSetResponderChild);
412 extracted = extractForTouchStart(CHILD_ID);
413 - expect(spies.onStartShouldSetResponderChild.callCount).toBe(1);
414 - expect(spies.onMoveShouldSetResponderParent.callCount).toBe(0); // none yet
413 + expect(spies.onStartShouldSetResponderChild.calls.length).toBe(1);
414 + expect(spies.onMoveShouldSetResponderParent.calls.length).toBe(0); // none yet
415 assertGrantEvent(CHILD_ID, extracted); // Child is the current responder
416
417 extracted = extractForTouchMove(CHILD_ID);
418 - expect(spies.onMoveShouldSetResponderParent.callCount).toBe(1);
418 + expect(spies.onMoveShouldSetResponderParent.calls.length).toBe(1);
419 assertGrantEvent(PARENT_ID, extracted);
420 assertTerminateEvent(CHILD_ID, extracted);
421
@@ -430,7 +430,7 @@ describe('ResponderEventPlugin', function() {
430
431 var extracted = extractForTouchStart(CHILD_ID);
432 assertNothingExtracted(extracted);
433 - expect(spies.onStartShouldSetResponderChild.callCount).toBe(1);
433 + expect(spies.onStartShouldSetResponderChild.calls.length).toBe(1);
434 expect(ResponderEventPlugin.getResponderID()).toBe(CHILD_ID);
435 extractForTouchEnd(CHILD_ID); // Clear the responder
436 expect(ResponderEventPlugin.getResponderID()).toBe(null);
@@ -440,7 +440,7 @@ describe('ResponderEventPlugin', function() {
440 onStartShouldSetResponder(CHILD_ID, spies.onStartShouldSetResponderChild);
441 extracted = extractForTouchStart(CHILD_ID);
442 assertNothingExtracted(extracted);
443 - expect(spies.onStartShouldSetResponderChild.callCount).toBe(2);
443 + expect(spies.onStartShouldSetResponderChild.calls.length).toBe(2);
444 expect(ResponderEventPlugin.getResponderID()).toBe(null);
445 extractForTouchEnd(CHILD_ID); // Clear the responder
446
@@ -449,7 +449,7 @@ describe('ResponderEventPlugin', function() {
449 onStartShouldSetResponder(CHILD_ID, spies.onStartShouldSetResponderChild);
450 onResponderGrant(CHILD_ID, onGrantChild);
451 extracted = extractForTouchStart(CHILD_ID);
452 - expect(spies.onStartShouldSetResponderChild.callCount).toBe(3);
452 + expect(spies.onStartShouldSetResponderChild.calls.length).toBe(3);
453 assertGrantEvent(CHILD_ID, extracted);
454 extracted = extractForTouchEnd(CHILD_ID); // Clear the responder
455 assertRelease(CHILD_ID, extracted);
@@ -473,16 +473,16 @@ describe('ResponderEventPlugin', function() {
473 spies.onStartShouldSetResponderChild.andReturn(true);
474 onStartShouldSetResponder(CHILD_ID, spies.onStartShouldSetResponderChild);
475 extracted = extractForTouchStart(CHILD_ID);
476 - expect(spies.onStartShouldSetResponderChild.callCount).toBe(1);
477 - expect(spies.onMoveShouldSetResponderParent.callCount).toBe(0); // none yet
476 + expect(spies.onStartShouldSetResponderChild.calls.length).toBe(1);
477 + expect(spies.onMoveShouldSetResponderParent.calls.length).toBe(0); // none yet
478 assertGrantEvent(CHILD_ID, extracted); // Child is the current responder
479
480 extracted = extractForTouchMove(CHILD_ID);
481 - expect(spies.onMoveShouldSetResponderParent.callCount).toBe(1);
481 + expect(spies.onMoveShouldSetResponderParent.calls.length).toBe(1);
482 assertNothingExtracted(extracted);
483
484 extracted = extractForScroll(CHILD_ID); // Could have been parent here too.
485 - expect(spies.onScrollShouldSetResponderParent.callCount).toBe(1);
485 + expect(spies.onScrollShouldSetResponderParent.calls.length).toBe(1);
486 assertGrantEvent(PARENT_ID, extracted);
487 assertTerminateEvent(CHILD_ID, extracted);
488
src/browser/ui/__tests__/ReactDOMComponent-test.js
+1 -1
@@ -492,7 +492,7 @@ describe('ReactDOMComponent', function() {
492
493 spyOn(console, 'warn');
494 ReactTestUtils.renderIntoDocument(<div onScroll={function(){}} />);
495 - expect(console.warn.callCount).toBe(1);
495 + expect(console.warn.calls.length).toBe(1);
496 expect(console.warn.mostRecentCall.args[0]).toBe(
497 'This browser doesn\'t support the `onScroll` event'
498 );
src/browser/ui/__tests__/ReactDOMIDOperations-test.js
+1 -1
@@ -36,7 +36,7 @@ describe('ReactDOMIDOperations', function() {
36 ).toBe('testID');
37
38 expect(
39 - DOMPropertyOperations.setValueForProperty.callCount
39 + DOMPropertyOperations.setValueForProperty.calls.length
40 ).toBe(0);
41 });
42
src/browser/ui/dom/__tests__/CSSPropertyOperations-test.js
+1 -1
@@ -163,7 +163,7 @@ describe('CSSPropertyOperations', function() {
163 color: 'red; '
164 });
165
166 - expect(console.warn.callCount).toBe(2);
166 + expect(console.warn.calls.length).toBe(2);
167 expect(console.warn.argsForCall[0][0]).toContain('Try "backgroundColor: blue" instead');
168 expect(console.warn.argsForCall[1][0]).toContain('Try "color: red" instead');
169 });
src/core/__tests__/ReactCompositeComponent-test.js
+1 -1
@@ -441,7 +441,7 @@ describe('ReactCompositeComponent', function() {
441 // lifecycle methods, because a componentWillMount implementation is
442 // likely call this.getDOMNode(), which will repopulate the node cache
443 // after it's been cleared, causing a memory leak.
444 - expect(ReactMount.purgeID.callCount).toBe(0);
444 + expect(ReactMount.purgeID.calls.length).toBe(0);
445 innerUnmounted = true;
446 },
447 render: function() {
src/core/__tests__/ReactMultiChild-test.js
+2 -2
@@ -190,7 +190,7 @@ describe('ReactMultiChild', function() {
190 container
191 );
192 expect(setInnerHTML).toHaveBeenCalled();
193 - var callCountOnMount = setInnerHTML.callCount;
193 + var callCountOnMount = setInnerHTML.calls.length;
194
195 React.render(
196 <div>
@@ -200,7 +200,7 @@ describe('ReactMultiChild', function() {
200 </div>,
201 container
202 );
203 - expect(setInnerHTML.callCount).toBe(callCountOnMount + 1);
203 + expect(setInnerHTML.calls.length).toBe(callCountOnMount + 1);
204 });
205 });
206 });