-
Notifications
You must be signed in to change notification settings - Fork 47.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement createNodeMock for ReactTestRenderer #7649
Changes from all commits
d7bd655
f24dbcd
cf63a1b
86f13a1
5c73a3d
4b1f273
ff6171d
b27a7f8
839e353
1145e6c
c33d571
3e5ca78
4f18142
780b641
eb6b129
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ var ReactTestComponent = function(element) { | |
this._renderedChildren = null; | ||
this._topLevelWrapper = null; | ||
}; | ||
|
||
ReactTestComponent.prototype.mountComponent = function( | ||
transaction, | ||
nativeParent, | ||
|
@@ -52,6 +53,7 @@ ReactTestComponent.prototype.mountComponent = function( | |
var element = this._currentElement; | ||
this.mountChildren(element.props.children, transaction, context); | ||
}; | ||
|
||
ReactTestComponent.prototype.receiveComponent = function( | ||
nextElement, | ||
transaction, | ||
|
@@ -60,13 +62,17 @@ ReactTestComponent.prototype.receiveComponent = function( | |
this._currentElement = nextElement; | ||
this.updateChildren(nextElement.props.children, transaction, context); | ||
}; | ||
|
||
ReactTestComponent.prototype.getHostNode = function() {}; | ||
ReactTestComponent.prototype.getPublicInstance = function() { | ||
// I can't say this makes a ton of sense but it seems better than throwing. | ||
// Maybe we'll revise later if someone has a good use case. | ||
return null; | ||
|
||
ReactTestComponent.prototype.getPublicInstance = function(transaction) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add a newline before this line too for consistency now that we’ve put some of them between methods. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're already calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep it the way it is. If we want to make this cleaner we should just use ES6 classes instead but this should be done separately. We should not mix stylistic and meaningful changes in the same PR. |
||
var element = this._currentElement; | ||
var options = transaction.getTestOptions(); | ||
return options.createNodeMock(element); | ||
}; | ||
|
||
ReactTestComponent.prototype.unmountComponent = function() {}; | ||
|
||
ReactTestComponent.prototype.toJSON = function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
var {children, ...props} = this._currentElement.props; | ||
var childrenJSON = []; | ||
|
@@ -136,7 +142,6 @@ ReactComponentEnvironment.injection.injectEnvironment({ | |
|
||
var ReactTestRenderer = { | ||
create: ReactTestMount.render, | ||
|
||
/* eslint-disable camelcase */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And keep this one, so the diff is smaller. In general better not to formatting changes to code you didn’t directly touch unless it’s horribly formatted |
||
unstable_batchedUpdates: ReactUpdates.batchedUpdates, | ||
/* eslint-enable camelcase */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
this.reactMountReady
is accessed viagetReactMountReady()
, let’s addgetMockConfig()
for consistency and use that instead outside.