@samitouri / QOS-React-2 / commits / 1c241b3ebc

Ensure PropTypes test works when warning module is replaced

For example, warning might be replaced with a module that throws errors, as is the case internally when running tests. Previously we were whitelisting this test to provide time to update callsites. Now we aren't and it fails.

Paul O’Shannessy committed Oct 27, 2014 at 16:58 UTC 1c241b3ebc36bd996353b5e93421128616b37c18
1 file changed +26 -2
src/core/__tests__/ReactPropTypes-test.js
+26 -2
@@ -407,8 +407,32 @@ describe('ReactPropTypes', function() {
407 });
408
409 it('should still work for deprecated typechecks', function() {
410 - typeCheckPass(PropTypes.renderable, []);
411 - typeCheckPass(PropTypes.renderable.isRequired, []);
410 + // We can't use typeCheckPass here because the warning module may do
411 + // something different in some environments. Luckily they should be fine
412 + // if they detect that console.warn is spied upon.
413 + spyOn(console, 'warn');
414 +
415 + // typeCheckPass(PropTypes.renderable, []);
416 + var error = PropTypes.renderable(
417 + {testProp: []},
418 + 'testProp',
419 + 'testComponent',
420 + ReactPropTypeLocations.prop
421 + );
422 +
423 + expect(error).toBe(undefined);
424 + expect(console.warn.calls.length).toBe(1);
425 +
426 + // typeCheckPass(PropTypes.renderable.isRequired, []);
427 + error = PropTypes.renderable.isRequired(
428 + {testProp: []},
429 + 'testProp',
430 + 'testComponent',
431 + ReactPropTypeLocations.prop
432 + );
433 +
434 + expect(error).toBe(undefined);
435 + expect(console.warn.calls.length).toBe(1);
436 });
437 });
438