redux-dynamic-modules icon indicating copy to clipboard operation
redux-dynamic-modules copied to clipboard

Add more example options

Open subtirelumihail opened this issue 6 years ago • 4 comments

Please add more examples, because there is now example on how we can test a component that has been wrapped in the DynamicModuleLoader ?

subtirelumihail avatar May 16 '19 13:05 subtirelumihail

Can you give an example of what exactly you are trying to test?

Dynamic module loader just adds redux artifacts to the store. The underlying components and its tests need not know about redux-dynamic-modules.

navneet-g avatar May 16 '19 20:05 navneet-g

So I have a component that looks like this:

const Example = () => (
  <DynamicModuleLoader modules={[module()]}>
    <ExampleComponent />
  </DynamicModuleLoader>
);

I want to be able to test this component without using the react-redux Provider component

describe('Example', () => {
  it('should render correctly', () => {
    render(
      <Provider store={store}>
        <Example />
      </Provider>
    );
  });
});

So basically what I mean is can I mock DynamicModuleLoader ?

subtirelumihail avatar May 17 '19 09:05 subtirelumihail

The ExampleComponent should know nothing about DynamicModuleLoader. What is the test case and asserts you expect in your test? Are you trying to test that the component is wrapped with DynamicModuleLoader with given set of modules?

navneet-g avatar May 22 '19 15:05 navneet-g

@navneet-g Yes

Also how should we mock the initialActions in a test case ?

subtirelumihail avatar Jul 10 '19 16:07 subtirelumihail