-
-
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.
Add context introspection API to Wrappers
- Loading branch information
1 parent
46f4d36
commit a295181
Showing
15 changed files
with
153 additions
and
4 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,32 @@ | ||
# `.context([key]) => Any` | ||
|
||
Returns the context hash for the root node of the wrapper. Optionally pass in a prop name and it | ||
will return just that value. | ||
|
||
|
||
#### Arguments | ||
|
||
1. `key` (`String` [optional]): If provided, the return value will be the `this.context[key]` of the | ||
root component instance. | ||
|
||
|
||
|
||
#### Example | ||
|
||
|
||
```jsx | ||
const wrapper = mount( | ||
<MyComponent />, | ||
{ options: { context: { foo: 10 } } } | ||
); | ||
|
||
expect(wrapper.context().foo).to.equal(10); | ||
expect(wrapper.context('foo')).to.equal(10); | ||
``` | ||
|
||
|
||
#### Related Methods | ||
|
||
- [`.state([key]) => Any`](state.md) | ||
- [`.props() => Object`](props.md) | ||
- [`.prop(key) => Any`](prop.md) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# `.context([key]) => Any` | ||
|
||
Returns the context hash for the root node of the wrapper. Optionally pass in a prop name and it | ||
will return just that value. | ||
|
||
|
||
#### Arguments | ||
|
||
1. `key` (`String` [optional]): If provided, the return value will be the `this.context[key]` of the | ||
root component instance. | ||
|
||
|
||
|
||
#### Example | ||
|
||
|
||
```jsx | ||
const wrapper = shallow( | ||
<MyComponent />, | ||
{ options: { context: { foo: 10 } } } | ||
); | ||
expect(wrapper.context().foo).to.equal(10); | ||
expect(wrapper.context('foo')).to.equal(10); | ||
``` | ||
|
||
|
||
#### Related Methods | ||
|
||
- [`.props() => Object`](props.md) | ||
- [`.prop(key) => Any`](prop.md) | ||
- [`.state([key]) => Any`](state.md) |
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
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