-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Docs ab #1947
Docs ab #1947
Conversation
- Defined 'solo' as a wrapper with one node, and used that terminology throughout. Removed the term 'current node' as applied to a wrapper, and changed each to better wording. - rewrote sections for functions matchesElement, containsMatchingElement, containsAllMatchingElements, containsAnyMatchingElements; each refer to containsMatchIngElement and matchesElement for matching rules. Renamed the matcher node to 'patternNode' to avoid confusion. - compared Shallow and React wrapper methods, corrected a few discrepancies - added some notes for methods in React or Shallow that are not in the other - added .length to both the React and Shallow directories.
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.
It'd be very helpful if these could be broken up into separate commits for each kind of change - as it is, this is quite a lot to review.
@@ -6,8 +6,7 @@ Enzyme | |||
[![npm Version](https://img.shields.io/npm/v/enzyme.svg)](https://www.npmjs.com/package/enzyme) [![License](https://img.shields.io/npm/l/enzyme.svg)](https://www.npmjs.com/package/enzyme) [![Build Status](https://travis-ci.org/airbnb/enzyme.svg)](https://travis-ci.org/airbnb/enzyme) [![Coverage Status](https://coveralls.io/repos/airbnb/enzyme/badge.svg?branch=master&service=github)](https://coveralls.io/github/airbnb/enzyme?branch=master) | |||
|
|||
|
|||
Enzyme is a JavaScript Testing utility for React that makes it easier to assert, manipulate, | |||
and traverse your React Components' output. | |||
Enzyme is a JavaScript Testing utility for React that makes it easier to test your React Components' output. |
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.
Why this change? The previous version was correct - i think it's important to mention manipulation and traversal.
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.
Just because something is technically correct, doesn't mean it's informative to someone who's never used Enzyme. When I first read that, I dismissed it as technical mumbo-jumbo. I didn't want to assert, manipulate or traverse, I wanted to test my software. I had to do the tut to figure out what enzyme does. This is the elevator speech; you have to make it as simple as possible. Maybe instead of 'test' it could be 'verify' or 'analyze'. I get it that you can simulate some stuff; maybe 'analyze' can cover that, too.
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.
I definitely like "test" over "assert" (although the two are largely synonymous), but manipulation and traversal are critical means of testing.
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.
what kind of 'manipulation'? certainly you can do stuff with these wrappers, but I don't think you can actually change, say, the nesting of nodes. You can run them through some runtime simulations: simulate, state, props, etc. I can't think of a simple word for this.
I'm trying to think of someway that 'traverse' might be considered part of 'test'. I'm not trying to take the wind out of enzyme's sails, I just want a naive reader to say "That's exactly what I need!"
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.
it is now:
Enzyme is a JavaScript Testing utility for React that makes it easier to test your React Components' output.
You can also manipulate, traverse and in some ways simulate runtime given the output.
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.
You can set props and state.
docs/api/ReactWrapper/closest.md
Outdated
current node's ancestors in the tree, starting with itself. | ||
|
||
Note: can only be called on a wrapper of a single node. | ||
wrapped node's ancestors in the tree, starting with itself. The wrapper must be solo. |
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.
I don't think "solo" is a particularly clear term; "a single node" seems clearer to me. Can these changes be reverted?
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.
Well, it's referring to a wrapper, so the whole phrase is "wrapper of a single node". That's 5 words. "Single-node wrapper" is 3 words; I was trying to get it down to two words. There's a lot of methods that only work on single-node wrappers, and a lot of functions that return them. In fact, it's almost like they're a subclass of Wrapper, with their own methods like closest, instance, etc. I count 17 such methods. We don't need a subclass, just a noun. You can get away with defining a term in just a few well-traveled places, say like "must be a solo wrapper (with just 1 child)". They figure it out.
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.
Word count isn't the thing that's going to solely determine how easy it is to digest; people can skim over phrases just as easily as words.
I don't want to invent a new noun in the quest for reducing confusion.
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.
How about we just stick to 'single-node wrapper'?
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.
Sounds good to me!
# `.containsAllMatchingElements(nodes) => Boolean` | ||
# `.containsAllMatchingElements(patternNodes) => Boolean` | ||
|
||
Returns whether or not all of the given react elements in `patternNodes` match an element in the wrapper's render tree. Every single element of `patternNodes` must be matched one or more times. Matching follows the rules for `containsMatchingElement`. |
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.
containsMatchingElement
should probably be a related method here
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.
also, doesn't this matching really follow the rules of matchesElement
?
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.
Yeah. lemme clean this up more.
|
||
Returns whether or not one of the given react elements is matching on element in the render tree. | ||
It will determine if an element in the wrapper __looks like__ one of the expected element by checking if all props of the expected element are present on the wrappers element and equals to each other. | ||
Returns whether or not at least one of the given react elements in `patternNodes` matches an element in the wrapper's render tree. One or more elements of `patternNodes` must be matched one or more times. Matching follows the rules for `containsMatchingElement`. |
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.
containsMatchingElement
should probably be a related method here
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.
fixed
@@ -12,7 +12,7 @@ Returns whether or not the current node exists. Or, if a selector is passed in, | |||
|
|||
#### Returns | |||
|
|||
`Boolean`: whether or not the current node exists, or the selector had any results. | |||
`Boolean`: whether or not any nodes are on the list, or the selector had any matches. |
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.
"on the list" isn't really a term that makes sense to me; maybe "the wrapper contains any nodes"?
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.
changing it to
...whether or not any nodes exist in the wrapper
|
||
### 2. Prop Selector |
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.
Why remove this section?
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.
it's part of regular CSS so I merged it into the CSS case. Isn't it?
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.
It's a bit different, because you can select on prop values - which can be numbers or booleans as well as strings. CSS selectors only and exclusively operate on string values.
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.
yeah, but the result looks almost the same. '[num=51]' will match num={51}, but not num='51'. And, '[num="51"]' will match num='51' but not num={51}. I think that should get a better description.
Meanwhile, these constructs can mix in with the rest of the CSS selector, so isn't it a part of CSS?
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.
It would be good to have a full accounting of the differences between enzyme selectors and css selectors. There was one phrase in there, "Further, enzyme supports combining any of those supported syntaxes together to uniquely identify a single node." I misinterpreted that to mean you can only select one node if you combine syntaxes. I rewrote the section.
@@ -79,11 +78,11 @@ const myComponents = wrapper.find(MyComponent); | |||
|
|||
|
|||
|
|||
### 4. A React Component’s displayName | |||
### 3. A React Component’s displayName | |||
|
|||
enzyme allows you to find components based on a component’s `displayName`. If a component exists | |||
in a render tree where its `displayName` is set and has its first character as a capital letter, |
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.
this isn't technically accurate; for example, things like withSomeHOC(ComponentName)
can also be found in many cases (as noted below); perhaps this sentence needs updating as well?
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.
I don't understand what the problem is. Isn't displayName sortof self-service?
docs/api/render.md
Outdated
@@ -1,6 +1,7 @@ | |||
# Static Rendering API | |||
|
|||
enzyme's `render` function is used to render react components to static HTML and analyze the | |||
Use enzyme's `render` function to generate HTML text from your React tree, |
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.
"HTML text" is a contradiction; something is either HTML, or text. "static HTML" is the proper term here.
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.
and I thought of 'static' as meaning, 'class-based' or 'standing in one spot', neither of which made sense. how about just 'HTML'?
@@ -1,14 +1,15 @@ | |||
# `.type() => String|Function|null` | |||
# `.type() => String | Function | null` |
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.
I believe the jsdoc-based convention here is to not have spaces around the |
, even if it's less readable that way.
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.
i'll put them back
So are we done with this? I think I have in all the changes for now. Am I supposed to complete conversations or something?
|
I'll rebase it and take another pass :-) thanks for your patience! |
63193df
to
2932d8c
Compare
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.
Thanks, this was a lot of effort and it's much appreciated!
thanks!
Allan Bonadio bojnac -at- tactileint.org portfolio.tactileint.org <http://portfolio.tactileint.org/> resume.tactileint.org <http://resume.tactileint.org/>
… On Jan 21, 2019, at 2:34 PM, Jordan Harband ***@***.***> wrote:
Merged #1947 <#1947> into master.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#1947 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AA91oG3S0HLFuQCfHjLyc3hwBd0JODM5ks5vFkBZgaJpZM4ZVvFc>.
|
Overhaul to a lot of ReactWrapper and ShallowWrapper method files, plus others.
Closes #1919.