mirror of
https://github.com/facebook/react.git
synced 2026-02-27 03:07:57 +00:00
@@ -108,10 +108,6 @@ describe('ReactDOM', function() {
|
||||
expect(dog.className).toBe('bigdog');
|
||||
});
|
||||
|
||||
it('should be a valid class', function() {
|
||||
expect(React.isValidClass(ReactDOM.div)).toBe(false);
|
||||
});
|
||||
|
||||
it('allow React.DOM factories to be called without warnings', function() {
|
||||
spyOn(console, 'warn');
|
||||
var element = React.DOM.div();
|
||||
|
||||
@@ -77,7 +77,7 @@ var React = {
|
||||
renderToString: ReactServerRendering.renderToString,
|
||||
renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,
|
||||
unmountComponentAtNode: ReactMount.unmountComponentAtNode,
|
||||
isValidClass: ReactLegacyElement.isValidFactory,
|
||||
isValidClass: ReactLegacyElement.isValidClass,
|
||||
isValidElement: ReactElement.isValidElement,
|
||||
withContext: ReactContext.withContext,
|
||||
|
||||
|
||||
@@ -227,6 +227,17 @@ ReactLegacyElementFactory.isValidFactory = function(factory) {
|
||||
factory.isReactLegacyFactory === LEGACY_MARKER;
|
||||
};
|
||||
|
||||
ReactLegacyElementFactory.isValidClass = function(factory) {
|
||||
if (__DEV__) {
|
||||
warning(
|
||||
false,
|
||||
'isValidClass is deprecated and will be removed in a future release. ' +
|
||||
'Use a more specific validator instead.'
|
||||
);
|
||||
}
|
||||
return ReactLegacyElementFactory.isValidFactory(factory);
|
||||
};
|
||||
|
||||
ReactLegacyElementFactory._isLegacyCallWarningEnabled = true;
|
||||
|
||||
module.exports = ReactLegacyElementFactory;
|
||||
|
||||
@@ -878,7 +878,10 @@ describe('ReactCompositeComponent', function() {
|
||||
expect(ReactMount.purgeID.callCount).toBe(4);
|
||||
});
|
||||
|
||||
it('should detect valid CompositeComponent classes', function() {
|
||||
it('should warn but detect valid CompositeComponent classes', function() {
|
||||
var warn = console.warn;
|
||||
console.warn = mocks.getMockFunction();
|
||||
|
||||
var Component = React.createClass({
|
||||
render: function() {
|
||||
return <div/>;
|
||||
@@ -886,9 +889,17 @@ describe('ReactCompositeComponent', function() {
|
||||
});
|
||||
|
||||
expect(React.isValidClass(Component)).toBe(true);
|
||||
|
||||
expect(console.warn.mock.calls.length).toBe(1);
|
||||
expect(console.warn.mock.calls[0][0]).toContain(
|
||||
'isValidClass is deprecated and will be removed in a future release'
|
||||
);
|
||||
});
|
||||
|
||||
it('should detect invalid CompositeComponent classes', function() {
|
||||
it('should warn but detect invalid CompositeComponent classes', function() {
|
||||
var warn = console.warn;
|
||||
console.warn = mocks.getMockFunction();
|
||||
|
||||
var FnComponent = function() {
|
||||
return false;
|
||||
};
|
||||
@@ -903,6 +914,13 @@ describe('ReactCompositeComponent', function() {
|
||||
expect(React.isValidClass(FnComponent)).toBe(false);
|
||||
expect(React.isValidClass(NullComponent)).toBe(false);
|
||||
expect(React.isValidClass(TrickFnComponent)).toBe(false);
|
||||
|
||||
expect(console.warn.mock.calls.length).toBe(3);
|
||||
console.warn.mock.calls.forEach(function(call) {
|
||||
expect(call[0]).toContain(
|
||||
'isValidClass is deprecated and will be removed in a future release'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should warn when shouldComponentUpdate() returns undefined', function() {
|
||||
|
||||
Reference in New Issue
Block a user