Skip to content
This repository was archived by the owner on May 17, 2019. It is now read-only.

Commit 67f08d6

Browse files
ganemonefusion-bot[bot]
authored and
fusion-bot[bot]
committed
Export mock wrapped with provider
#21
1 parent 749d81d commit 67f08d6

File tree

6 files changed

+713
-11
lines changed

6 files changed

+713
-11
lines changed

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ In addition to defining action/reducer pairs, the `incrementReactor` HOC also ma
138138

139139
Reactors typically need to be used in conjunction with `connect` from `react-redux`, in order to map state to React.
140140

141-
Below is an example of consuming the state and RPC methods that are made available from the Redux store and the RPC plugin.
141+
Below is an example of consuming the state and RPC methods that are made available from the Redux store and the RPC plugin.
142142

143143
```js
144144
// src/components/example.js
@@ -171,7 +171,7 @@ export default hoc(Example);
171171

172172
Redux colocates all valid actions in a respective "slot" in the state tree, and colocates the structuring of the state tree via helpers such as `combineReducers`. This means that a reducer can be unit tested by simply calling the reducer with one of the valid actions, without having any effect on any other state that might exist in the app. The downside is that if an action needs to modify multiple "slots" in the state tree, it can be tedious to find all transformations pertaining to any given action.
173173

174-
Another point worth mentioning is that with traditional reducers, it's possible to refactor the state tree in such a way that doesn't make any changes to reducers or components (albeit it does require changing the reducer composition chain as well as all relevant `mapStateToProps` functions).
174+
Another point worth mentioning is that with traditional reducers, it's possible to refactor the state tree in such a way that doesn't make any changes to reducers or components (albeit it does require changing the reducer composition chain as well as all relevant `mapStateToProps` functions).
175175

176176
Reactors, on the other hand, colocate a single reducer to a single action, so all state transformations pertaining to any given action are handled by a single function. This comes at the cost of flexibility: it's no longer possible to refactor the shape of the state tree without changing every affectd reducer, and it's also possible to affect unrelated parts of the state tree, for example missing properties due to an overly conservative object assignment.
177177

@@ -206,3 +206,20 @@ const NewComponent = withRPCReactor('rpcId', {
206206
transformParams(params) => ({}), // optional
207207
})(Component);
208208
```
209+
210+
### Testing
211+
212+
The package also exports a mock rpc plugin which can be useful for testing. For example:
213+
214+
```js
215+
import {mock as MockRPC} from 'fusion-plugin-rpc-redux-react';
216+
app.plugin(mock, {
217+
handlers: {
218+
getUser: (args) => {
219+
return {
220+
mock: 'data',
221+
}
222+
}
223+
}
224+
});
225+
```

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,15 @@
4646
"fusion-core": "^0.2.5",
4747
"fusion-react": "^0.1.10",
4848
"fusion-react-async": "0.1.4",
49+
"fusion-test-utils": "^0.2.1",
4950
"nyc": "^11.3.0",
50-
"prettier": "1.8.2",
51+
"prettier": "1.9.0",
5152
"react": "^16.2.0",
5253
"react-dom": "16.2.0",
54+
"react-redux": "^5.0.6",
5355
"react-test-renderer": "^16.2.0",
56+
"redux": "^3.7.2",
57+
"redux-reactors": "^1.0.3",
5458
"tape-cup": "^4.7.1",
5559
"unitest": "^1.1.0"
5660
},

0 commit comments

Comments
 (0)