diff --git a/scripts/fiber/tests-passing.txt b/scripts/fiber/tests-passing.txt index 5eb43be0ba..b2952dfe3d 100644 --- a/scripts/fiber/tests-passing.txt +++ b/scripts/fiber/tests-passing.txt @@ -159,7 +159,6 @@ src/isomorphic/classic/__tests__/ReactContextValidator-test.js * should check child context types * should warn (but not error) if getChildContext method is missing * should pass parent context if getChildContext method is missing -* should only warn about missing getChildContext once per component type src/isomorphic/classic/class/__tests__/ReactBind-test.js * Holds reference to instance diff --git a/src/isomorphic/classic/__tests__/ReactContextValidator-test.js b/src/isomorphic/classic/__tests__/ReactContextValidator-test.js index cd844e9f52..883764e067 100644 --- a/src/isomorphic/classic/__tests__/ReactContextValidator-test.js +++ b/src/isomorphic/classic/__tests__/ReactContextValidator-test.js @@ -294,20 +294,36 @@ describe('ReactContextValidator', () => { it('should warn (but not error) if getChildContext method is missing', () => { spyOn(console, 'error'); - var MyComponent = React.createClass({ - childContextTypes: { + class ComponentA extends React.Component { + static childContextTypes = { foo: React.PropTypes.string.isRequired, - }, - - render: function() { + }; + render() { return
; - }, - }); + } + } + class ComponentB extends React.Component { + static childContextTypes = { + foo: React.PropTypes.string.isRequired, + }; + render() { + return
; + } + } - ReactTestUtils.renderIntoDocument(); + ReactTestUtils.renderIntoDocument(); expectDev(console.error.calls.count()).toBe(1); expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe( - 'Warning: getChildContext() is not defined for MyComponent' + 'Warning: getChildContext() is not defined for ComponentA' + ); + + // Warnings should be deduped by component type + ReactTestUtils.renderIntoDocument(); + expectDev(console.error.calls.count()).toBe(1); + ReactTestUtils.renderIntoDocument(); + expectDev(console.error.calls.count()).toBe(2); + expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(1)[0])).toBe( + 'Warning: getChildContext() is not defined for ComponentB' ); }); @@ -356,38 +372,4 @@ describe('ReactContextValidator', () => { expect(childContext.foo).toBe('FOO'); }); - it('should only warn about missing getChildContext once per component type', () => { - spyOn(console, 'error'); - - class ComponentA extends React.Component { - static childContextTypes = { - foo: React.PropTypes.string.isRequired, - }; - render() { - return
; - } - } - class ComponentB extends React.Component { - static childContextTypes = { - foo: React.PropTypes.string.isRequired, - }; - render() { - return
; - } - } - - ReactTestUtils.renderIntoDocument(); - expectDev(console.error.calls.count()).toBe(1); - expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe( - 'Warning: getChildContext() is not defined for ComponentA' - ); - ReactTestUtils.renderIntoDocument(); - expectDev(console.error.calls.count()).toBe(1); - ReactTestUtils.renderIntoDocument(); - expectDev(console.error.calls.count()).toBe(2); - expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(1)[0])).toBe( - 'Warning: getChildContext() is not defined for ComponentB' - ); - }); - });