File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -120,16 +120,17 @@ The second one is setHoistStaticMethod where you can override [hoist-non-react-s
120
120
121
121
## How to mock in tests
122
122
123
- To test a component wrapped in ` select ` , mock ` context.$Utils.$PermissionValidator .getState() ` and ` context.$Utils.$Dispatcher.listen() ` .
123
+ To test a component wrapped in ` select ` , mock ` context.$Utils.$PageStateManager .getState() ` and ` context.$Utils.$Dispatcher.listen() ` .
124
124
125
125
Example:
126
126
127
127
``` js
128
+
129
+ import { mount } from ' enzyme' ;
130
+ import { PageContext } from ' @ima/react-page-renderer' ;
131
+
128
132
const context = {
129
133
$Utils: {
130
- $PermissionValidator: {
131
- hasPermission: hasPermissionMock,
132
- },
133
134
$PageStateManager: {
134
135
getState: jest .fn (),
135
136
},
@@ -139,8 +140,13 @@ const context = {
139
140
},
140
141
};
141
142
142
- const setup = setupMountFactory (AuthedComponent, context);
143
- const wrapper = setup (props);
143
+ const wrapper = mount (
144
+ React .createElement (
145
+ PageContext .Provider ,
146
+ { value: context },
147
+ React .createElement (MyComponent, { permissions })
148
+ )
149
+ );
144
150
145
151
context .$Utils .$PageStateManager .getState .mockReturnValue ({foo: ' bar' })
146
152
You can’t perform that action at this time.
0 commit comments