This repository was archived by the owner on Jan 27, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
packages/redux-dynostore-react-redux-subspace/test Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -276,3 +276,54 @@ describe('mapExtraState tests', () => {
276
276
) . toThrow ( TypeError )
277
277
} )
278
278
} )
279
+
280
+ describe ( 'subspaceOptions tests' , ( ) => {
281
+ const mockStore = configureStore ( [ ] )
282
+ let store
283
+
284
+ const CustomContext = React . createContext ( )
285
+
286
+ class TestComponent extends React . Component {
287
+ render ( ) {
288
+ return < p > { this . props . testKey } </ p >
289
+ }
290
+ }
291
+
292
+ const mapStateToProps = state => ( {
293
+ testKey : state . testKey
294
+ } )
295
+
296
+ const ConnectedTestComponent = connect (
297
+ mapStateToProps ,
298
+ null ,
299
+ null ,
300
+ { context : CustomContext }
301
+ ) ( TestComponent )
302
+
303
+ beforeEach ( ( ) => {
304
+ store = mockStore ( {
305
+ testId : {
306
+ testKey : 'root value'
307
+ } ,
308
+ parentId : {
309
+ testId : {
310
+ testKey : 'nested value'
311
+ }
312
+ }
313
+ } )
314
+ } )
315
+
316
+ test ( 'should create subspaced enhanced component using custom context' , ( ) => {
317
+ const SubspacedComponent = subspaced ( { context : CustomContext } ) ( 'testId' ) ( store ) ( ConnectedTestComponent )
318
+
319
+ const { getByText } = render (
320
+ < Provider store = { store } context = { CustomContext } >
321
+ < SubspaceProvider mapState = { state => state . parentId } namespace = "parentId" context = { CustomContext } >
322
+ < SubspacedComponent />
323
+ </ SubspaceProvider >
324
+ </ Provider >
325
+ )
326
+
327
+ expect ( getByText ( 'nested value' ) ) . toBeDefined ( )
328
+ } )
329
+ } )
You can’t perform that action at this time.
0 commit comments