-
-
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.
- Loading branch information
1 parent
a8fc7f4
commit 8138b73
Showing
11 changed files
with
329 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
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,34 @@ | ||
# `.name() => String|null` | ||
|
||
Returns the name of the current node of this wrapper. If it's a composite component, this will be | ||
the name of the component. If it's native DOM node, it will be a string of the tag name. If it's | ||
`null`, it will be `null`. | ||
|
||
The order of precedence on returning the name is: `type.displayName` -> `type.name` -> `type`. | ||
|
||
Note: can only be called on a wrapper of a single node. | ||
|
||
|
||
#### Returns | ||
|
||
`String|null`: The name of the current node | ||
|
||
|
||
|
||
#### Examples | ||
|
||
```jsx | ||
const wrapper = mount(<div/>); | ||
expect(wrapper.name()).to.equal('div'); | ||
``` | ||
|
||
```jsx | ||
const wrapper = mount(<Foo />); | ||
expect(wrapper.name()).to.equal('Foo'); | ||
``` | ||
|
||
```jsx | ||
Foo.displayName = 'A cool custom name'; | ||
const wrapper = mount(<Foo />); | ||
expect(wrapper.name()).to.equal('A cool custom name'); | ||
``` |
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,36 @@ | ||
# `.name() => String|null` | ||
|
||
Returns the name of the current node of this wrapper. If it's a composite component, this will be | ||
the name of the top-most rendered component. If it's native DOM node, it will be a string of the | ||
tag name. If it's `null`, it will be `null`. | ||
|
||
The order of precedence on returning the name is: `type.displayName` -> `type.name` -> `type`. | ||
|
||
Note: can only be called on a wrapper of a single node. | ||
|
||
|
||
#### Returns | ||
|
||
`String|null`: The name of the current node | ||
|
||
|
||
|
||
#### Examples | ||
|
||
```jsx | ||
const wrapper = shallow(<div/>); | ||
expect(wrapper.name()).to.equal('div'); | ||
``` | ||
|
||
```jsx | ||
const SomeWrappingComponent = () => <Foo />; | ||
const wrapper = shallow(<SomeWrappingComponent />); | ||
expect(wrapper.name()).to.equal('Foo'); | ||
``` | ||
|
||
```jsx | ||
Foo.displayName = 'A cool custom name'; | ||
const SomeWrappingComponent = () => <Foo />; | ||
const wrapper = shallow(<SomeWrappingComponent />); | ||
expect(wrapper.name()).to.equal('A cool custom name'); | ||
``` |
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
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
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
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
Oops, something went wrong.