title: Unit testing react hook inside react-admin
body: <p>Is there any way to mock the user authenticated status using useAuthState as a mock?</p>
  <p>Things i have tried so far include: React Hooks Testing Library, Enzyme component rendering, jest.mock, jest.createMockFromModule. I know if i don't include my component inside a provider i will get &quot;could not find react-redux context value; please ensure the component is wrapped in a Provider&quot;</p>
  <pre><code>import React from 'react';
  import { makeStyles } from '@material-ui/core';
  import Typography from '@material-ui/core/Typography';
  import { useAuthState } from 'ra-core';
  import { Redirect } from 'react-router';
  import { Routes } from '../../ui/constants';
  import { UnAuthenticatedLayoutWithTheme } from '../UnAuthenticatedLayout';
  
  export const GettingStarted = () =&gt; {
      const classes = useStyles();
      const { loading, authenticated } = useAuthState();
  
      if (loading) {
          return null;
      }
  
      if (authenticated) {
          return &lt;Redirect to={Routes.default} /&gt;;
      }
  
      return (
          &lt;UnAuthenticatedLayoutWithTheme showActions&gt;
              &lt;Typography
                  variant=&quot;h3&quot;
                  align=&quot;center&quot;
                  className={classes.sectionTitle}
              &gt;
                  Onboarding
              &lt;/Typography&gt;
  ...
  </code></pre>
  <pre><code>test('should display page with user not authenticated', async() =&gt; {
          const { getByText } = renderWithRedux(
              &lt;ApiHubProvider url=&quot;/getting-started&quot; tenantName=&quot;getting-started&quot;&gt;
                   &lt;GettingStarted /&gt;
              &lt;/ApiHubProvider&gt;
          );
  
          await wait(() =&gt; {
              expect(getByText('Onboarding')).not.toBeNull();
          });
      });
  </code></pre>
  <p>ApiHubProvider Implementation</p>
  <pre><code>import React, { createContext, useContext, useRef } from 'react';
  import get from 'lodash/get';
  
  export const ApiHubContext = createContext();
  
  export const ApiHubProvider = ({
      url,
      tenantName,
      originHubName,
      children,
  }) =&gt; {
      const value = useRef({
          originHubName,
          tenantName,
          url,
          urlWithApi: `${url}/api`,
          urlWithTenant: `${url}/api/${tenantName}`,
      });
      return (
          &lt;ApiHubContext.Provider value={value.current}&gt;
              {children}
          &lt;/ApiHubContext.Provider&gt;
      );
  };
  </code></pre>