redux-auto icon indicating copy to clipboard operation
redux-auto copied to clipboard

Add another test example to Readme

Open codemeasandwich opened this issue 2 years ago • 0 comments

Would be nice to have an example calling an action

// @ts-ignore: Unreachable code error
import actions from 'redux-auto';
import { render } from '@testing-library/react';
import React, { useEffect } from 'react';
import { connect } from 'react-redux';

jest.unmock('redux-auto');
jest.mock('axios', () => ({
  get: ()=> Promuse.resolve({ name: 'tome' }),
}));

const Component = () => {
  useEffect(() => {
    actions.server.call();
  }, []);
  return <>tset</>;
};

const mapStateToProps = () => ({});

const WrapperComponent = connect(mapStateToProps)(Component);

describe.only('#foo -> bar', () => {
  it('should return the something when calling the server', () => {
    render(
      <ProviderStoreToTests>
        <WrapperComponent />
      </ProviderStoreToTests>
    );
    expect(actions.server.call).toBeCalled();
  });
});

codemeasandwich avatar Dec 07 '22 11:12 codemeasandwich