Include static properties in jest mocks for core components

Summary: This is necessary to provide things like `Image.prefetch` in Jest tests. Previously this only gave access to propTypes.

Reviewed By: sahrens

Differential Revision: D8526494

fbshipit-source-id: 11d49d95d6edf3f75c90438e0b629f5345bc980d
This commit is contained in:
Eli White 2018-06-19 21:28:00 -07:00 committed by Facebook Github Bot
parent e7256a777e
commit 66aeeff2f9
1 changed files with 3 additions and 3 deletions

View File

@ -48,9 +48,9 @@ module.exports = (moduleName, instanceMethods) => {
}
};
if (RealComponent.propTypes != null) {
Component.propTypes = RealComponent.propTypes;
}
Object.keys(RealComponent).forEach(classStatic => {
Component[classStatic] = RealComponent[classStatic];
});
if (instanceMethods != null) {
Object.assign(Component.prototype, instanceMethods);