-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from themouette/features/shallow-equals
Add `equals` method to ShallowWrapper.
- Loading branch information
Showing
3 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# `.equals(node) => Boolean` | ||
|
||
Returns whether or not the current wrapper root node render tree looks like the one passed in. | ||
|
||
|
||
#### Arguments | ||
|
||
1. `node` (`ReactElement`): The node whose presence you are detecting in the current instance's | ||
render tree. | ||
|
||
|
||
|
||
#### Returns | ||
|
||
`Boolean`: whether or not the current wrapper has a node anywhere in it's render tree that looks | ||
like the one passed in. | ||
|
||
|
||
|
||
#### Example | ||
|
||
|
||
```jsx | ||
const wrapper = shallow(<MyComponent />); | ||
expect(wrapper.equals(<div className="foo bar" />)).to.equal(true); | ||
``` | ||
|
||
|
||
#### Common Gotchas | ||
|
||
- `.equals()` expects a ReactElement, not a selector (like many other methods). Make sure that | ||
when you are calling it you are calling it with a ReactElement or a JSX expression. | ||
- Keep in mind that this method determines equality based on the equality of the node's children as | ||
well. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters