title: Unit Test case for Sorting in Jest
body: <p>I am new to reactjs and jest. I am trying to write a test case that will pass the sort function written in container. I am not sure how to write it.</p>
  
  <p>I am getting  <code>TypeError: Cannot read property 'sort' of undefined</code> error when I try to run the test case.</p>
  
  <p>Actual Array</p>
  
  <pre><code>let testArray=[{trackingId:'1',updated: '1512885243'},
                  {trackingId:'1',updated: '1512485253'},
                  {trackingId:'3',updated: '1512884233'},
                  {trackingId:'2',updated: '1512885243'}];
  </code></pre>
  
  <p>Expected Array</p>
  
  <pre><code>let sortedArray = [{trackingId: '1', updated: '1512885243'},
                     {trackingId: '1', updated: '1512885253'},
                   {trackingId: '2', updated: '1512885243'},
                   {trackingId: '3', updated: '1512884233'}]
  
  // I am thinking something like:
  describe('Sorting', () =&gt; {
        it('Array should be sortedby trackingId', () =&gt; {
          testArray.sort((a,b) =&gt; {
            if (a.trackingId !== b.trackingId) {
              return a.trackingId - b.trackingId;
            }
            return new Date(b.updated) - new Date(a.updated);
          });
          expect(component.contains(result))
            .toEqual(expect.arrayContaining(sortedArray))
  
  });
  </code></pre>
  
  <p>Sort function in my container class for which I am writing the unit test:</p>
  
  <pre><code>customerTrackingInfo = customerTrackingInfo.sort( (a,b) =&gt; {
          if (a.trackingId !== b.trackingId) {
            return a.trackingId - b.trackingId;
          }
          return new Date(b.updated) - new Date(a.updated);
  });
  </code></pre>