Removed redundant gCC test

This commit is contained in:
Brian Vaughn
2017-01-12 16:58:36 -08:00
parent 4f08884b5d
commit e17cc98a89
2 changed files with 25 additions and 44 deletions
-1
View File
@@ -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
@@ -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 <div />;
},
});
}
}
class ComponentB extends React.Component {
static childContextTypes = {
foo: React.PropTypes.string.isRequired,
};
render() {
return <div />;
}
}
ReactTestUtils.renderIntoDocument(<MyComponent/>);
ReactTestUtils.renderIntoDocument(<ComponentA/>);
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(<ComponentA/>);
expectDev(console.error.calls.count()).toBe(1);
ReactTestUtils.renderIntoDocument(<ComponentB/>);
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 <div />;
}
}
class ComponentB extends React.Component {
static childContextTypes = {
foo: React.PropTypes.string.isRequired,
};
render() {
return <div />;
}
}
ReactTestUtils.renderIntoDocument(<ComponentA/>);
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(<ComponentA/>);
expectDev(console.error.calls.count()).toBe(1);
ReactTestUtils.renderIntoDocument(<ComponentB/>);
expectDev(console.error.calls.count()).toBe(2);
expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(1)[0])).toBe(
'Warning: getChildContext() is not defined for ComponentB'
);
});
});