title: Testing Redux : Should tests of a Reducer use actions or not?
body: <p>I'm currently learning Redux.
  So far, as I'm discovering how to manage a state app, I don't want to focus on any integration with a framework (like React). I just want to well understand the idea and concepts behind Redux.</p>
  
  <p>I followed courses given by Dan Abramov on <a href="https://egghead.io/lessons/javascript-redux-the-single-immutable-state-tree?course=getting-started-with-redux" rel="nofollow">egghead.io</a>.</p>
  
  <p>I like the way he explains by testing his app so I started playing with Redux the same way.</p>
  
  <p>I built an app with Redux. Of course it has multiple reducers and actions.
  I won't share any code here because it has no particular interest.</p>
  
  <p>It's more a matter of how to deal with tests and Redux.</p>
  
  <p><strong>I don't know if it makes sense to test reducers with their corresponding actions of if I should mock the actions in my tests.</strong></p>
  
  <p>I started by mocking the actions because at first, I thought that it was a good idea to separate my tests and not having dependencies between reducers and actions. (and it's what I've seen in most tutorials. But in tutorials they often build small app).</p>
  
  <p>Now, I figure out that I sometimes end up with a mock different than the corresponding action and even if my tests are fine, it could break in a real app when I'll use dispatch(myAction()) as it will be something different than exepected.</p>
  
  <p><strong>Should I use my actions in my reducers tests ?</strong></p>
  
  <p>Thanks a lot for any explanation about that.</p>
  
  <p>EDIT : Some code to have a better explanation</p>
  
  <h2>REDUCER</h2>
  
  <pre><code>case CREATE_USER_IN_PROJECT:
      currentProject = state.filter(p =&gt; p.id === action.payload.idProjet)[0]
  
      indexCurrentProject = state.indexOf(currentProject)
  
      people = [
          ...currentProject.people,
          action.payload.idUser
      ]
  
      return [
          ...state.slice(0, indexCurrentProject),
          Object.assign({}, currentProject, {people}),
          ...state.slice(indexCurrentProject + 1)
      ]
  </code></pre>
  
  <h2>REDUCER'S TEST</h2>
  
  <pre><code>it('CREATE_PROJECT if no project should only have the new project', done =&gt; {
      let idNewProject = uuid.v4()
  
      expect(
          projects(undefined, {
              type: CREATE_PROJECT,
              payload: {
                  id: idNewProject,
                  name: 'New project !'
              }
          })
      )
      .toEqual([{
          id: idNewProject,
          name: 'New project !',
          people: [],
          money: '€',
          operations: [],
          archived: false,
          closed: false
      }])
  
      done()
  })
  </code></pre>
  
  <p>So here, instead of having </p>
  
  <pre><code>{
      type: CREATE_PROJECT,
      payload: {
          id: idNewProject,
          name: 'New project !'
      }
  }
  </code></pre>
  
  <p>Should I call my action <code>createProject('New project !')</code> ?</p>