title: How to test componentDidUpdate()?
body: <p>This is an example implementation:</p>
  
  <pre><code>export class Person extends Component {
    componentDidMount() {
      const { onLoadProfile, onLoadPolicy, person } = this.props
      onLoadProfile(person.profile.uri)
      onLoadPolicy(person.policy.uri)
    }
  
    componentDidUpdate(prevProps) {
      const { onLoadProfile, onLoadPolicy, person } = this.props
      const prevPerson = prevProps.person.uri
      const curPerson = person.uri
  
      // If person has changed, update Person component
      if (prevPerson !== curPerson) {
        onLoadProfile(person.profile.uri)
        onLoadPolicy(person.policy.uri)
      }
    }
  }
  </code></pre>
  
  <p>On <code>componentDidMount()</code>, I've managed to test it like this:</p>
  
  <pre><code>describe('&lt;Person /&gt;', () =&gt; {
    let props
    let mountedPerson
    const mockLoadProfile = jest.fn()
    const mockLoadPolicy = jest.fn()
  
    const person = () =&gt; {
      if (!mountedPerson) {
        mountedPerson = mount(&lt;Person {...props} /&gt;)
      } 
      return mountedPerson
    }
  
    beforeEach(() =&gt; {
      props = {
        onLoadProfile = mockLoadProfile,
        onLoadPolicy = mockLoadPolicy
      }
      mountedPerson = undefined
    })
  
    afterEach(() =&gt; {
      mockLoadProfile.mockClear()
      mockLoadPolicy.mockClear()
    })
  
    describe('componentDidMount', () =&gt; {
      it('loads profile', () =&gt; {
        person().instance().componentDidMount()
        expect(mockLoadProfile).toBeCalled()
      })
  
      it('loads policy', () =&gt; {
        person().instance().componentDidMount()
        expect(mockLoadPolicy).toBeCalled()
      })
    })
  })
  </code></pre>
  
  <p>On <code>componentDidUpdate()</code>, I'd need the component to attempt to <code>render()</code> twice in order to verify if it updates when it should and vice-versa, yet I couldn't find a proper way to do it. </p>
  
  <p>What is the correct approach to test a <code>componentDidUpdate()</code> method in React?</p>
  
  <p>PS.: I'm using <strong>jest</strong>, <strong>enzyme</strong> and <strong>React 15</strong>.</p>