title: React Simple Unit Test for Reducer
body: <p>I am trying to do a simple unit test for a reducer in react.js.
  I passed undefined as the initial state and an empty action as the second parameter in the test for the reducer. I expected the test to pass but i get an error as shown below. This complaining about what i am passing into the reducer.Can anyone tell me how to overcome this. Thanks</p>
  
  <pre><code>TypeError: (0 , _Global2.default) is not a function
        at Object.it (src/__tests__/Global.test.js:5:33)
            at new Promise (&lt;anonymous&gt;)
        at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
  </code></pre>
  
  <p>Heres my Global state with the reducer</p>
  
  <pre><code>const loginVisibility = Object.freeze({
      Visible: 'VISIBLE',
      Hidden: 'HIDDEN'
  });
  const initialState = { show: false };
  
  export const actionCreators = {
    hideLogin: () =&gt; ({ 
      type: loginVisibility.Hidden,
    }),
    showLogin: () =&gt; ({ 
      type: loginVisibility.Visible,
    }),
  };
  
  export const reducer = (state, action) =&gt; {
    state = state || initialState;
  
    if (action.type === loginVisibility.Visible) {
      return { ...state, show: true };
    }
  
    if (action.type === loginVisibility.Hidden) {
      return { ...state, show: false };
    }
  
    return state;
  };
  </code></pre>
  
  <p>And here is my Global.test.js file</p>
  
  <pre><code>import reducer from '../store/state/Global';
  
  describe('Login Visibility',()=&gt;{
   it('Should return the initial state',()=&gt;{
     expect(reducer(undefined,{})).toEqual({
        show: false
     })
   })
  });
  </code></pre>