Skip to content

Commit 8062bc3

Browse files
committed
plugin-select-readme Use Enzyme mount instead of cusom helper tool
1 parent 1680f5f commit 8062bc3

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

packages/plugin-select/README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,17 @@ The second one is setHoistStaticMethod where you can override [hoist-non-react-s
120120

121121
## How to mock in tests
122122

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()`.
124124

125125
Example:
126126

127127
```js
128+
129+
import { mount } from 'enzyme';
130+
import { PageContext } from '@ima/react-page-renderer';
131+
128132
const context = {
129133
$Utils: {
130-
$PermissionValidator: {
131-
hasPermission: hasPermissionMock,
132-
},
133134
$PageStateManager: {
134135
getState: jest.fn(),
135136
},
@@ -139,8 +140,13 @@ const context = {
139140
},
140141
};
141142

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+
);
144150

145151
context.$Utils.$PageStateManager.getState.mockReturnValue({foo: 'bar'})
146152

0 commit comments

Comments
 (0)