@@ -9,6 +9,41 @@ define your own `createStore` method to return an instance of your Redux store,
99` initialState ` and ` middlewares ` that this class provides - it is important to ensure that your
1010store uses these, because if it disregards them, none of the methods this class provides will function.
1111
12+ Extensions to the returned ` ReduxWrapper `
13+ -----------------------------------------
14+
15+ The return type of the ` mount ` method extends Enzyme's ` ReactWrapper ` by adding a store property to
16+ it, so you can access the store instance that the component was mounted with. This is useful for
17+ some edge cases where you may want to test how your component reacts to actions being dispatched
18+ outside of the component's scope.
19+
20+ For example:
21+ ``` typescript jsx
22+ const component = new WrapperWithRedux (SomeComponent );
23+
24+ describe (" when testing a scenario" , () => {
25+ const wrapper = component
26+ .withReduxState ({
27+ test: {
28+ value: " Scenario value 1"
29+ }
30+ })
31+ .mount ();
32+
33+ it (" renders the initial value" , () => {
34+ expect (wrapper .find (" .SomeComponent--value" ).text ()).toBe (" Initial value" );
35+ });
36+
37+ it (" dispatches actions.setValue" , () => {
38+ wrapper .store .dispatch (actions .setValue (" New value" ));
39+ });
40+
41+ it (" renders the updated value" , () => {
42+ expect (wrapper .find (" .SomeComponent--value" ).text ()).toBe (" New value" );
43+ });
44+ });
45+ ```
46+
1247
1348Public read-only properties
1449---------------------------
@@ -17,10 +52,6 @@ Public read-only properties
1752An array of actions that have been dispatched, used when asserting that actions have been
1853dispatched as expected during interactions or in the component lifecycle.
1954
20- ### ` store `
21- The instance of the Redux store used. However, this is only available after calling ` mount ` .
22- If accessed prior to mounting your component, it will be ` undefined ` .
23-
2455
2556Public methods
2657--------------
@@ -41,6 +72,9 @@ Sets the default Redux store state to be used for the wrapper instance.
4172### ` withReduxState `
4273Sets the scenario-specific Redux store state to be used - cleared after ` mount ` , ` render ` or ` shallow ` are called.
4374
75+ ### ` mount `
76+ Mounts the component with the Enzyme ` mount ` function, using the currently-set data.
77+ Returns a ` ReactWrapper ` instance, which also includes a ` store ` property.
4478
4579How to extend for use in your project
4680-------------------------------------
0 commit comments