title: Unit test with moment.js
body: <p>I'm new to writing unit tests.</p>
  <p>My function looks like this:</p>
  <pre><code>getData() {
  return this.parameters.map(p =&gt; {
          return {
              name: p.name,
              items: p.items.map(item =&gt; {
  
                  const toTime = item.hasOwnProperty('end') ? moment.utc(item.end._d).unix() : null;
                  const fromTime = item.hasOwnProperty('start') ? moment.utc(item.start._d).unix() : null;
  
                  return {
                      id: item.id,
                      fromTime: fromTime,
                      toTime: toTime,
                  };
              }),
          };
      });
  }
  </code></pre>
  <p>and so far my Jasmine test looks like this:</p>
  <pre><code>describe('getData()', function() {
  it('should return json data', function() {
      $ctrl.parameters = [{
          name: 'test',
          items: [{
              id: 1,
              fromTime: null,
              toTime: null
          }, {
              id: 13,
              fromTime: null,
              toTime: null
  
          }]
      }];
  
      expect($ctrl.getData()).toEqual([{
          name: 'test',
          items: [{
              id: 1,
              fromTime: null,
              toTime: null
          }, {
              id: 13,
              fromTime: null,
              toTime: null
          }]
      }]);
  });
  });
  </code></pre>
  <p>This test is working/passing, but as you can see I am not testing the ternary if/else that uses Moment.js. Basically what the ternary does is check if items contains a property called <code>start</code> / <code>end</code> and if it does, convert that value to a epoch/Unix timestamp and assign it to either <code>toTime</code> or <code>fromTime</code>.</p>
  <p>So if items had a property called end with a value of <code>'Sat Oct 31 2015 00:00:00 GMT+0000 (GMT)'</code>, then it would be converted to <code>'1446249600'</code> and assigned to <code>toTime</code>.</p>
  <p>How can I write a test for it?</p>